Changeset 7b616e2 in mainline for uspace/srv/ns/task.c


Ignore:
Timestamp:
2017-09-27T22:40:09Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d076f16
Parents:
8d6bcc8c
Message:

Name service should communicate using async.h.

File:
1 edited

Legend:

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

    r8d6bcc8c r7b616e2  
    3232 */
    3333
    34 #include <ipc/ipc.h>
    3534#include <adt/hash_table.h>
     35#include <async.h>
    3636#include <stdbool.h>
    3737#include <errno.h>
     
    182182                        continue;
    183183               
    184                 if (!(pr->callid & IPC_CALLID_NOTIFICATION)) {
    185                         texit = ht->have_rval ? TASK_EXIT_NORMAL :
    186                             TASK_EXIT_UNEXPECTED;
    187                         ipc_answer_2(pr->callid, EOK, texit,
    188                             ht->retval);
    189                 }
     184                texit = ht->have_rval ? TASK_EXIT_NORMAL :
     185                    TASK_EXIT_UNEXPECTED;
     186                async_answer_2(pr->callid, EOK, texit, ht->retval);
    190187               
    191188                list_remove(&pr->link);
     
    203200        if (ht == NULL) {
    204201                /* No such task exists. */
    205                 ipc_answer_0(callid, ENOENT);
     202                async_answer_0(callid, ENOENT);
    206203                return;
    207204        }
     
    210207                task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
    211208                    TASK_EXIT_UNEXPECTED;
    212                 ipc_answer_2(callid, EOK, texit, ht->retval);
     209                async_answer_2(callid, EOK, texit, ht->retval);
    213210                return;
    214211        }
     
    218215            (pending_wait_t *) malloc(sizeof(pending_wait_t));
    219216        if (!pr) {
    220                 if (!(callid & IPC_CALLID_NOTIFICATION))
    221                         ipc_answer_0(callid, ENOMEM);
     217                async_answer_0(callid, ENOMEM);
    222218                return;
    223219        }
     
    282278int ns_task_retval(ipc_call_t *call)
    283279{
     280        task_id_t id = call->in_task_id;
     281       
     282        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     283        hashed_task_t *ht = (link != NULL) ?
     284            hash_table_get_inst(link, hashed_task_t, link) : NULL;
     285       
     286        if ((ht == NULL) || (ht->finished))
     287                return EINVAL;
     288       
     289        ht->finished = true;
     290        ht->have_rval = true;
     291        ht->retval = IPC_GET_ARG1(*call);
     292       
     293        process_pending_wait();
     294       
     295        return EOK;
     296}
     297
     298int ns_task_disconnect(ipc_call_t *call)
     299{
    284300        task_id_t id;
    285301        int rc = get_id_by_phone(call->in_phone_hash, &id);
     
    287303                return rc;
    288304       
    289         ht_link_t *link = hash_table_find(&task_hash_table, &id);
    290         hashed_task_t *ht = (link != NULL) ?
    291             hash_table_get_inst(link, hashed_task_t, link) : NULL;
    292        
    293         if ((ht == NULL) || (ht->finished))
    294                 return EINVAL;
    295        
    296         ht->finished = true;
    297         ht->have_rval = true;
    298         ht->retval = IPC_GET_ARG1(*call);
    299        
    300         process_pending_wait();
    301        
    302         return EOK;
    303 }
    304 
    305 int ns_task_disconnect(ipc_call_t *call)
    306 {
    307         task_id_t id;
    308         int rc = get_id_by_phone(call->in_phone_hash, &id);
    309         if (rc != EOK)
    310                 return rc;
    311        
    312305        /* Delete from phone-to-id map. */
    313306        hash_table_remove(&phone_to_id, &call->in_phone_hash);
Note: See TracChangeset for help on using the changeset viewer.