Changes in uspace/srv/ns/task.c [4e00f87:1c635d6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/task.c
r4e00f87 r1c635d6 34 34 #include <ipc/ipc.h> 35 35 #include <adt/hash_table.h> 36 #include < bool.h>36 #include <stdbool.h> 37 37 #include <errno.h> 38 38 #include <assert.h> … … 40 40 #include <macros.h> 41 41 #include <malloc.h> 42 #include <types/task.h> 42 43 #include "task.h" 43 44 #include "ns.h" 44 45 45 46 /* TODO:47 *48 * As there is currently no convention that each task has to be waited49 * for, the NS can leak memory because of the zombie tasks.50 *51 */52 46 53 47 /** Task hash table item. */ … … 179 173 180 174 loop: 181 list_foreach(pending_wait, cur) { 182 pending_wait_t *pr = list_get_instance(cur, pending_wait_t, link); 183 175 list_foreach(pending_wait, link, pending_wait_t, pr) { 184 176 ht_link_t *link = hash_table_find(&task_hash_table, &pr->id); 185 177 if (!link) … … 197 189 } 198 190 199 hash_table_remove(&task_hash_table, &pr->id); 200 list_remove(cur); 191 list_remove(&pr->link); 201 192 free(pr); 202 193 goto loop; … … 206 197 void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid) 207 198 { 208 sysarg_t retval;209 task_exit_t texit;210 211 199 ht_link_t *link = hash_table_find(&task_hash_table, &id); 212 200 hashed_task_t *ht = (link != NULL) ? … … 219 207 } 220 208 221 if (!ht->finished) { 222 /* Add to pending list */ 223 pending_wait_t *pr = 224 (pending_wait_t *) malloc(sizeof(pending_wait_t)); 225 if (!pr) { 226 retval = ENOMEM; 227 goto out; 228 } 229 230 link_initialize(&pr->link); 231 pr->id = id; 232 pr->callid = callid; 233 list_append(&pr->link, &pending_wait); 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); 234 213 return; 235 214 } 236 215 237 hash_table_remove_item(&task_hash_table, link); 238 retval = EOK; 239 240 out: 241 if (!(callid & IPC_CALLID_NOTIFICATION)) { 242 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED; 243 ipc_answer_2(callid, retval, texit, ht->retval); 244 } 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); 245 229 } 246 230 … … 313 297 ht->retval = IPC_GET_ARG1(*call); 314 298 299 process_pending_wait(); 300 315 301 return EOK; 316 302 } … … 335 321 ht->finished = true; 336 322 323 process_pending_wait(); 324 hash_table_remove(&task_hash_table, &id); 325 337 326 return EOK; 338 327 }
Note:
See TracChangeset
for help on using the changeset viewer.