Changes in uspace/srv/ns/task.c [166a1f57:234f47e] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/task.c
r166a1f57 r234f47e 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 bool remove = false;211 212 199 ht_link_t *link = hash_table_find(&task_hash_table, &id); 213 200 hashed_task_t *ht = (link != NULL) ? … … 220 207 } 221 208 222 if (!ht->finished) { 223 /* Add to pending list */ 224 pending_wait_t *pr = 225 (pending_wait_t *) malloc(sizeof(pending_wait_t)); 226 if (!pr) { 227 retval = ENOMEM; 228 goto out; 229 } 230 231 link_initialize(&pr->link); 232 pr->id = id; 233 pr->callid = callid; 234 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); 235 213 return; 236 214 } 237 215 238 remove = true; 239 retval = EOK; 240 241 out: 242 if (!(callid & IPC_CALLID_NOTIFICATION)) { 243 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED; 244 ipc_answer_2(callid, retval, texit, ht->retval); 245 } 246 if (remove) 247 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); 248 229 } 249 230 250 231 int ns_task_id_intro(ipc_call_t *call) 251 232 { 252 253 233 task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); 254 234 255 235 ht_link_t *link = hash_table_find(&phone_to_id, &call->in_phone_hash); 256 236 if (link != NULL) 257 return EEXIST S;237 return EEXIST; 258 238 259 239 p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t)); … … 262 242 263 243 hashed_task_t *ht = (hashed_task_t *) malloc(sizeof(hashed_task_t)); 264 if (ht == NULL) 244 if (ht == NULL) { 245 free(entry); 265 246 return ENOMEM; 247 } 266 248 267 249 /* … … 316 298 ht->retval = IPC_GET_ARG1(*call); 317 299 300 process_pending_wait(); 301 318 302 return EOK; 319 303 } … … 338 322 ht->finished = true; 339 323 324 process_pending_wait(); 325 hash_table_remove(&task_hash_table, &id); 326 340 327 return EOK; 341 328 }
Note:
See TracChangeset
for help on using the changeset viewer.