Changeset a35b458 in mainline for uspace/srv/ns/task.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/ns/task.c
r3061bc1 ra35b458 48 48 typedef struct { 49 49 ht_link_t link; 50 50 51 51 task_id_t id; /**< Task ID. */ 52 52 bool finished; /**< Task is done. */ … … 115 115 sysarg_t in_phone_hash = *(sysarg_t*)key; 116 116 p2i_entry_t *entry = hash_table_get_inst(item, p2i_entry_t, link); 117 117 118 118 return (in_phone_hash == entry->in_phone_hash); 119 119 } … … 157 157 return ENOMEM; 158 158 } 159 159 160 160 if (!hash_table_create(&phone_to_id, 0, 0, &p2i_ops)) { 161 161 printf(NAME ": No memory available for tasks\n"); 162 162 return ENOMEM; 163 163 } 164 164 165 165 list_initialize(&pending_wait); 166 166 return EOK; … … 171 171 { 172 172 task_exit_t texit; 173 173 174 174 loop: 175 175 list_foreach(pending_wait, link, pending_wait_t, pr) { … … 177 177 if (!link) 178 178 continue; 179 179 180 180 hashed_task_t *ht = hash_table_get_inst(link, hashed_task_t, link); 181 181 if (!ht->finished) 182 182 continue; 183 183 184 184 texit = ht->have_rval ? TASK_EXIT_NORMAL : 185 185 TASK_EXIT_UNEXPECTED; 186 186 async_answer_2(pr->callid, EOK, texit, ht->retval); 187 187 188 188 list_remove(&pr->link); 189 189 free(pr); … … 197 197 hashed_task_t *ht = (link != NULL) ? 198 198 hash_table_get_inst(link, hashed_task_t, link) : NULL; 199 199 200 200 if (ht == NULL) { 201 201 /* No such task exists. */ … … 203 203 return; 204 204 } 205 205 206 206 if (ht->finished) { 207 207 task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL : … … 210 210 return; 211 211 } 212 212 213 213 /* Add to pending list */ 214 214 pending_wait_t *pr = … … 218 218 return; 219 219 } 220 220 221 221 link_initialize(&pr->link); 222 222 pr->id = id; … … 228 228 { 229 229 task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); 230 230 231 231 ht_link_t *link = hash_table_find(&phone_to_id, &call->in_phone_hash); 232 232 if (link != NULL) 233 233 return EEXIST; 234 234 235 235 p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t)); 236 236 if (entry == NULL) 237 237 return ENOMEM; 238 238 239 239 hashed_task_t *ht = (hashed_task_t *) malloc(sizeof(hashed_task_t)); 240 240 if (ht == NULL) { … … 242 242 return ENOMEM; 243 243 } 244 244 245 245 /* 246 246 * Insert into the phone-to-id map. 247 247 */ 248 248 249 249 entry->in_phone_hash = call->in_phone_hash; 250 250 entry->id = id; 251 251 hash_table_insert(&phone_to_id, &entry->link); 252 252 253 253 /* 254 254 * Insert into the main table. 255 255 */ 256 256 257 257 ht->id = id; 258 258 ht->finished = false; … … 260 260 ht->retval = -1; 261 261 hash_table_insert(&task_hash_table, &ht->link); 262 262 263 263 return EOK; 264 264 } … … 269 269 if (link == NULL) 270 270 return ENOENT; 271 271 272 272 p2i_entry_t *entry = hash_table_get_inst(link, p2i_entry_t, link); 273 273 *id = entry->id; 274 274 275 275 return EOK; 276 276 } … … 279 279 { 280 280 task_id_t id = call->in_task_id; 281 281 282 282 ht_link_t *link = hash_table_find(&task_hash_table, &id); 283 283 hashed_task_t *ht = (link != NULL) ? 284 284 hash_table_get_inst(link, hashed_task_t, link) : NULL; 285 285 286 286 if ((ht == NULL) || (ht->finished)) 287 287 return EINVAL; 288 288 289 289 ht->finished = true; 290 290 ht->have_rval = true; 291 291 ht->retval = IPC_GET_ARG1(*call); 292 292 293 293 process_pending_wait(); 294 294 295 295 return EOK; 296 296 } … … 302 302 if (rc != EOK) 303 303 return rc; 304 304 305 305 /* Delete from phone-to-id map. */ 306 306 hash_table_remove(&phone_to_id, &call->in_phone_hash); 307 307 308 308 /* Mark task as finished. */ 309 309 ht_link_t *link = hash_table_find(&task_hash_table, &id); … … 312 312 313 313 hashed_task_t *ht = hash_table_get_inst(link, hashed_task_t, link); 314 314 315 315 ht->finished = true; 316 316 317 317 process_pending_wait(); 318 318 hash_table_remove(&task_hash_table, &id); 319 319 320 320 return EOK; 321 321 }
Note:
See TracChangeset
for help on using the changeset viewer.