Changeset 8e7c9fe in mainline for uspace/srv/ns/task.c
- Timestamp:
- 2014-09-12T03:45:25Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c53b58e
- Parents:
- 3eb0c85 (diff), 105d8d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/task.c
r3eb0c85 r8e7c9fe 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. */ … … 195 189 } 196 190 197 hash_table_remove(&task_hash_table, &pr->id);198 191 list_remove(&pr->link); 199 192 free(pr); … … 204 197 void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid) 205 198 { 206 sysarg_t retval;207 task_exit_t texit;208 bool remove = false;209 210 199 ht_link_t *link = hash_table_find(&task_hash_table, &id); 211 200 hashed_task_t *ht = (link != NULL) ? … … 218 207 } 219 208 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); 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); 233 213 return; 234 214 } 235 215 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); 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); 246 229 } 247 230 … … 314 297 ht->retval = IPC_GET_ARG1(*call); 315 298 299 process_pending_wait(); 300 316 301 return EOK; 317 302 } … … 336 321 ht->finished = true; 337 322 323 process_pending_wait(); 324 hash_table_remove(&task_hash_table, &id); 325 338 326 return EOK; 339 327 }
Note:
See TracChangeset
for help on using the changeset viewer.