Changes in uspace/srv/ns/task.c [a35b458:5a6cc679] in mainline


Ignore:
File:
1 edited

Legend:

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

    ra35b458 r5a6cc679  
    4848typedef struct {
    4949        ht_link_t link;
    50 
     50       
    5151        task_id_t id;    /**< Task ID. */
    5252        bool finished;   /**< Task is done. */
     
    115115        sysarg_t in_phone_hash = *(sysarg_t*)key;
    116116        p2i_entry_t *entry = hash_table_get_inst(item, p2i_entry_t, link);
    117 
     117       
    118118        return (in_phone_hash == entry->in_phone_hash);
    119119}
     
    157157                return ENOMEM;
    158158        }
    159 
     159       
    160160        if (!hash_table_create(&phone_to_id, 0, 0, &p2i_ops)) {
    161161                printf(NAME ": No memory available for tasks\n");
    162162                return ENOMEM;
    163163        }
    164 
     164       
    165165        list_initialize(&pending_wait);
    166166        return EOK;
     
    171171{
    172172        task_exit_t texit;
    173 
     173       
    174174loop:
    175175        list_foreach(pending_wait, link, pending_wait_t, pr) {
     
    177177                if (!link)
    178178                        continue;
    179 
     179               
    180180                hashed_task_t *ht = hash_table_get_inst(link, hashed_task_t, link);
    181181                if (!ht->finished)
    182182                        continue;
    183 
     183               
    184184                texit = ht->have_rval ? TASK_EXIT_NORMAL :
    185185                    TASK_EXIT_UNEXPECTED;
    186186                async_answer_2(pr->callid, EOK, texit, ht->retval);
    187 
     187               
    188188                list_remove(&pr->link);
    189189                free(pr);
     
    197197        hashed_task_t *ht = (link != NULL) ?
    198198            hash_table_get_inst(link, hashed_task_t, link) : NULL;
    199 
     199       
    200200        if (ht == NULL) {
    201201                /* No such task exists. */
     
    203203                return;
    204204        }
    205 
     205       
    206206        if (ht->finished) {
    207207                task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
     
    210210                return;
    211211        }
    212 
     212       
    213213        /* Add to pending list */
    214214        pending_wait_t *pr =
     
    218218                return;
    219219        }
    220 
     220       
    221221        link_initialize(&pr->link);
    222222        pr->id = id;
     
    228228{
    229229        task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call));
    230 
     230       
    231231        ht_link_t *link = hash_table_find(&phone_to_id, &call->in_phone_hash);
    232232        if (link != NULL)
    233233                return EEXIST;
    234 
     234       
    235235        p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t));
    236236        if (entry == NULL)
    237237                return ENOMEM;
    238 
     238       
    239239        hashed_task_t *ht = (hashed_task_t *) malloc(sizeof(hashed_task_t));
    240240        if (ht == NULL) {
     
    242242                return ENOMEM;
    243243        }
    244 
     244       
    245245        /*
    246246         * Insert into the phone-to-id map.
    247247         */
    248 
     248       
    249249        entry->in_phone_hash = call->in_phone_hash;
    250250        entry->id = id;
    251251        hash_table_insert(&phone_to_id, &entry->link);
    252 
     252       
    253253        /*
    254254         * Insert into the main table.
    255255         */
    256 
     256       
    257257        ht->id = id;
    258258        ht->finished = false;
     
    260260        ht->retval = -1;
    261261        hash_table_insert(&task_hash_table, &ht->link);
    262 
     262       
    263263        return EOK;
    264264}
     
    269269        if (link == NULL)
    270270                return ENOENT;
    271 
     271       
    272272        p2i_entry_t *entry = hash_table_get_inst(link, p2i_entry_t, link);
    273273        *id = entry->id;
    274 
     274       
    275275        return EOK;
    276276}
     
    279279{
    280280        task_id_t id = call->in_task_id;
    281 
     281       
    282282        ht_link_t *link = hash_table_find(&task_hash_table, &id);
    283283        hashed_task_t *ht = (link != NULL) ?
    284284            hash_table_get_inst(link, hashed_task_t, link) : NULL;
    285 
     285       
    286286        if ((ht == NULL) || (ht->finished))
    287287                return EINVAL;
    288 
     288       
    289289        ht->finished = true;
    290290        ht->have_rval = true;
    291291        ht->retval = IPC_GET_ARG1(*call);
    292 
     292       
    293293        process_pending_wait();
    294 
     294       
    295295        return EOK;
    296296}
     
    302302        if (rc != EOK)
    303303                return rc;
    304 
     304       
    305305        /* Delete from phone-to-id map. */
    306306        hash_table_remove(&phone_to_id, &call->in_phone_hash);
    307 
     307       
    308308        /* Mark task as finished. */
    309309        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     
    312312
    313313        hashed_task_t *ht = hash_table_get_inst(link, hashed_task_t, link);
    314 
     314       
    315315        ht->finished = true;
    316 
     316       
    317317        process_pending_wait();
    318318        hash_table_remove(&task_hash_table, &id);
    319 
     319       
    320320        return EOK;
    321321}
Note: See TracChangeset for help on using the changeset viewer.