Changeset 241f1985 in mainline for uspace/srv/taskman/event.c
- Timestamp:
- 2019-08-31T10:45:17Z (6 years ago)
- Children:
- 102f641
- Parents:
- f92b315
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-23 22:04:34)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-31 10:45:17)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/taskman/event.c
rf92b315 r241f1985 49 49 task_id_t id; /**< Task ID who we wait for. */ 50 50 task_id_t waiter_id; /**< Task ID who waits. */ 51 ipc_call id_t callid; /**< Call ID waiting for the event. */51 ipc_call_t *icall; /**< Call ID waiting for the event. */ 52 52 int flags; /**< Wait flags. */ 53 53 } pending_wait_t; … … 59 59 static FIBRIL_RWLOCK_INITIALIZE(listeners_lock); 60 60 61 int event_init(void)61 errno_t event_init(void) 62 62 { 63 63 list_initialize(&pending_waits); … … 150 150 int match = notify_flags & pr->flags; 151 151 // TODO why do I even accept such calls? 152 bool answer = !(pr-> callid & IPC_CALLID_NOTIFICATION);152 bool answer = !(pr->icall->flags & IPC_CALL_NOTIF); 153 153 154 154 if (match == 0) { … … 156 156 /* Nothing to wait for anymore */ 157 157 if (answer) { 158 async_answer_0(pr-> callid, EINTR);158 async_answer_0(pr->icall, EINTR); 159 159 } 160 160 } else { … … 165 165 if ((pr->flags & TASK_WAIT_BOTH) && match == TASK_WAIT_EXIT) { 166 166 /* No sense to wait for both anymore */ 167 async_answer_1(pr-> callid, EINTR, t->exit);167 async_answer_1(pr->icall, EINTR, t->exit); 168 168 } else { 169 169 /* Send both exit status and retval, caller 170 170 * should know what is valid */ 171 async_answer_3(pr-> callid, EOK, t->exit,171 async_answer_3(pr->icall, EOK, t->exit, 172 172 t->retval, rest); 173 173 } … … 195 195 196 196 void event_register_listener(task_id_t id, bool past_events, async_sess_t *sess, 197 ipc_call id_t iid)198 { 199 int rc = EOK;197 ipc_call_t *icall) 198 { 199 errno_t rc = EOK; 200 200 /* 201 201 * We have lock of tasks structures so that we can guarantee … … 219 219 * while we dump events. 220 220 */ 221 async_answer_0(i id, rc);221 async_answer_0(icall, rc); 222 222 if (past_events) { 223 223 task_foreach(&dump_walker, t->sess); … … 228 228 fibril_rwlock_write_unlock(&task_hash_table_lock); 229 229 if (rc != EOK) { 230 async_answer_0(i id, rc);231 } 232 } 233 234 void wait_for_task(task_id_t id, int flags, ipc_call id_t callid,230 async_answer_0(icall, rc); 231 } 232 } 233 234 void wait_for_task(task_id_t id, int flags, ipc_call_t *icall, 235 235 task_id_t waiter_id) 236 236 { … … 244 244 if (t == NULL) { 245 245 /* No such task exists. */ 246 async_answer_0( callid, ENOENT);246 async_answer_0(icall, ENOENT); 247 247 return; 248 248 } … … 250 250 if (t->exit != TASK_EXIT_RUNNING) { 251 251 //TODO are flags BOTH processed correctly here? 252 async_answer_3( callid, EOK, t->exit, t->retval, 0);252 async_answer_3(icall, EOK, t->exit, t->retval, 0); 253 253 return; 254 254 } … … 267 267 } 268 268 269 int rc = EOK;269 errno_t rc = EOK; 270 270 if (pr == NULL) { 271 271 pr = malloc(sizeof(pending_wait_t)); … … 279 279 pr->waiter_id = waiter_id; 280 280 pr->flags = flags; 281 pr-> callid = callid;281 pr->icall = icall; 282 282 283 283 list_append(&pr->link, &pending_waits); … … 288 288 * fibril). 289 289 */ 290 rc = EEXIST S;290 rc = EEXIST; 291 291 } else { 292 292 /* … … 294 294 */ 295 295 pr->flags &= ~TASK_WAIT_BOTH; // TODO maybe new flags should be set? 296 pr-> callid = callid;296 pr->icall = icall; 297 297 } 298 298 … … 300 300 fibril_rwlock_write_unlock(&pending_wait_lock); 301 301 // TODO why IPC_CALLID_NOTIFICATION? explain! 302 if (rc != EOK && !( callid & IPC_CALLID_NOTIFICATION)) {303 async_answer_0( callid, rc);304 } 305 } 306 307 308 int task_set_retval(task_id_t sender, int retval, bool wait_for_exit)309 { 310 int rc = EOK;302 if (rc != EOK && !(icall->flags & IPC_CALL_NOTIF)) { 303 async_answer_0(icall, rc); 304 } 305 } 306 307 308 errno_t task_set_retval(task_id_t sender, int retval, bool wait_for_exit) 309 { 310 errno_t rc = EOK; 311 311 312 312 fibril_rwlock_write_lock(&task_hash_table_lock);
Note:
See TracChangeset
for help on using the changeset viewer.