Changes in uspace/srv/ns/task.c [1c635d6:feeac0d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/task.c
r1c635d6 rfeeac0d 40 40 #include <macros.h> 41 41 #include <malloc.h> 42 #include <types/task.h>43 42 #include "task.h" 44 43 #include "ns.h" 45 44 45 46 /* TODO: 47 * 48 * As there is currently no convention that each task has to be waited 49 * for, the NS can leak memory because of the zombie tasks. 50 * 51 */ 46 52 47 53 /** Task hash table item. */ … … 189 195 } 190 196 197 hash_table_remove(&task_hash_table, &pr->id); 191 198 list_remove(&pr->link); 192 199 free(pr); … … 197 204 void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid) 198 205 { 206 sysarg_t retval; 207 task_exit_t texit; 208 bool remove = false; 209 199 210 ht_link_t *link = hash_table_find(&task_hash_table, &id); 200 211 hashed_task_t *ht = (link != NULL) ? … … 207 218 } 208 219 209 if (ht->finished) { 210 task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL : 211 TASK_EXIT_UNEXPECTED; 212 ipc_answer_2(callid, EOK, texit, ht->retval); 220 if (!ht->finished) { 221 /* Add to pending list */ 222 pending_wait_t *pr = 223 (pending_wait_t *) malloc(sizeof(pending_wait_t)); 224 if (!pr) { 225 retval = ENOMEM; 226 goto out; 227 } 228 229 link_initialize(&pr->link); 230 pr->id = id; 231 pr->callid = callid; 232 list_append(&pr->link, &pending_wait); 213 233 return; 214 234 } 215 235 216 /* Add to pending list */ 217 pending_wait_t *pr = 218 (pending_wait_t *) malloc(sizeof(pending_wait_t)); 219 if (!pr) { 220 if (!(callid & IPC_CALLID_NOTIFICATION)) 221 ipc_answer_0(callid, ENOMEM); 222 return; 223 } 224 225 link_initialize(&pr->link); 226 pr->id = id; 227 pr->callid = callid; 228 list_append(&pr->link, &pending_wait); 236 remove = true; 237 retval = EOK; 238 239 out: 240 if (!(callid & IPC_CALLID_NOTIFICATION)) { 241 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED; 242 ipc_answer_2(callid, retval, texit, ht->retval); 243 } 244 if (remove) 245 hash_table_remove_item(&task_hash_table, link); 229 246 } 230 247 … … 297 314 ht->retval = IPC_GET_ARG1(*call); 298 315 299 process_pending_wait();300 301 316 return EOK; 302 317 } … … 321 336 ht->finished = true; 322 337 323 process_pending_wait();324 hash_table_remove(&task_hash_table, &id);325 326 338 return EOK; 327 339 }
Note:
See TracChangeset
for help on using the changeset viewer.