Changeset adb49f58 in mainline for uspace/srv/ns/task.c


Ignore:
Timestamp:
2009-07-06T20:16:15Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
95bc57c
Parents:
0315679
Message:

Allow to determine whether a task returned value before terminatign.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/ns/task.c

    r0315679 radb49f58  
    5757typedef struct {
    5858        link_t link;
    59         task_id_t id;    /**< Task ID. */
    60         int retval;
    61         bool destroyed;
     59        task_id_t id;   /**< Task ID. */
     60        bool finished;  /**< Task is done. */
     61        bool have_rval; /**< Task returned a value. */
     62        int retval;     /**< The return value. */
    6263} hashed_task_t;
    6364
     
    212213{
    213214        link_t *cur;
     215        task_exit_t texit;
    214216       
    215217loop:
     
    227229               
    228230                hashed_task_t *ht = hash_table_get_instance(link, hashed_task_t, link);
    229                 if (!ht->destroyed)
     231                if (!ht->finished)
    230232                        continue;
    231233               
    232                 if (!(pr->callid & IPC_CALLID_NOTIFICATION))
    233                         ipc_answer_1(pr->callid, EOK, ht->retval);
    234                
     234                if (!(pr->callid & IPC_CALLID_NOTIFICATION)) {
     235                        texit = ht->have_rval ? TASK_EXIT_NORMAL :
     236                            TASK_EXIT_UNEXPECTED;
     237                        ipc_answer_2(pr->callid, EOK, texit,
     238                            ht->retval);
     239                }
     240
    235241                hash_table_remove(&task_hash_table, keys, 2);
    236242                list_remove(cur);
     
    243249{
    244250        ipcarg_t retval;
     251        task_exit_t texit;
     252
    245253        unsigned long keys[2] = {
    246254                LOWER32(id),
     
    258266        }
    259267
    260         if (!ht->destroyed) {
     268        if (!ht->finished) {
    261269                /* Add to pending list */
    262270                pending_wait_t *pr =
     
    277285       
    278286out:
    279         if (!(callid & IPC_CALLID_NOTIFICATION))
    280                 ipc_answer_1(callid, retval, ht->retval);
     287        if (!(callid & IPC_CALLID_NOTIFICATION)) {
     288                texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED;
     289                ipc_answer_2(callid, retval, texit, ht->retval);
     290        }
    281291}
    282292
     
    319329        link_initialize(&ht->link);
    320330        ht->id = id;
    321         ht->destroyed = false;
     331        ht->finished = false;
     332        ht->have_rval = false;
    322333        ht->retval = -1;
    323334        hash_table_insert(&task_hash_table, keys, &ht->link);
     
    343354            hash_table_get_instance(link, hashed_task_t, link) : NULL;
    344355       
    345         if ((ht == NULL) || ht->destroyed)
     356        if ((ht == NULL) || ht->finished)
    346357                return EINVAL;
    347358
     359        ht->finished = true;
     360        ht->have_rval = true;
    348361        ht->retval = IPC_GET_ARG1(*call);
    349362
     
    372385        hashed_task_t *ht =
    373386            hash_table_get_instance(link, hashed_task_t, link);
    374         assert(ht != NULL);
    375 
    376         ht->destroyed = true;
     387        if (ht == NULL)
     388                return EOK;
     389
     390        ht->finished = true;
    377391
    378392        return EOK;
Note: See TracChangeset for help on using the changeset viewer.