Changeset 241f1985 in mainline for uspace/srv/taskman/main.c


Ignore:
Timestamp:
2019-08-31T10:45:17Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
102f641
Parents:
f92b315
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-08-23 22:04:34)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2019-08-31 10:45:17)
Message:

Correcting failure from previous merge

The commits from Michal Koutný from the branch system-daemon
where built on a old version of Helenos. Because of this
many types and API functions have changed. This commit
upgrades the merge code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/taskman/main.c

    rf92b315 r241f1985  
    7171 * Static functions
    7272 */
    73 static void connect_to_loader(ipc_callid_t iid, ipc_call_t *icall)
    74 {
    75         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
     73static void connect_to_loader(ipc_call_t *icall)
     74{
     75        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id);
    7676        /* We don't accept the connection request, we forward it instead to
    7777         * freshly spawned loader. */
    78         int rc = loader_spawn("loader");
    79        
    80         if (rc != EOK) {
    81                 async_answer_0(iid, rc);
     78        errno_t rc = loader_spawn("loader");
     79       
     80        if (rc != EOK) {
     81                async_answer_0(icall, rc);
    8282                return;
    8383        }
     
    8989        /* Forward the connection request (strip interface arg). */
    9090        async_exch_t *exch = async_exchange_begin(sess_ref->sess);
    91         rc = async_forward_fast(iid, exch,
    92             IPC_GET_ARG2(*icall),
    93             IPC_GET_ARG3(*icall),
    94             0, IPC_FF_NONE);
     91        rc = async_forward_1(icall, exch,
     92            ipc_get_arg2(icall),
     93            ipc_get_arg3(icall),
     94            IPC_FF_NONE);
    9595        async_exchange_end(exch);
    9696
     
    100100
    101101        if (rc != EOK) {
    102                 async_answer_0(iid, rc);
     102                async_answer_0(icall, rc);
    103103                return;
    104104        }
     
    107107}
    108108
    109 static void connect_to_ns(ipc_callid_t iid, ipc_call_t *icall)
    110 {
    111         DPRINTF("%s, %llu\n", __func__, icall->in_task_id);
     109static void connect_to_ns(ipc_call_t *icall)
     110{
     111        DPRINTF("%s, %llu\n", __func__, icall->task_id);
    112112
    113113        /* Wait until we know NS */
     
    120120        /* Do not accept connection, forward it */
    121121        async_exch_t *exch = async_exchange_begin(session_ns);
    122         int rc = async_forward_fast(iid, exch, 0, 0, 0, IPC_FF_NONE);
     122        errno_t rc = async_forward_0(icall, exch, 0, IPC_FF_NONE);
    123123        async_exchange_end(exch);
    124124
    125125        if (rc != EOK) {
    126                 async_answer_0(iid, rc);
    127                 return;
    128         }
    129 }
    130 
    131 static void taskman_new_task(ipc_callid_t iid, ipc_call_t *icall)
    132 {
    133         int rc = task_intro(icall->in_task_id);
    134         async_answer_0(iid, rc);
    135 }
    136 
    137 static void taskman_i_am_ns(ipc_callid_t iid, ipc_call_t *icall)
    138 {
    139         DPRINTF("%s, %llu\n", __func__, icall->in_task_id);
    140         int rc = EOK;
     126                async_answer_0(icall, rc);
     127                return;
     128        }
     129}
     130
     131static void taskman_new_task(ipc_call_t *icall)
     132{
     133        errno_t rc = task_intro(icall->task_id);
     134        async_answer_0(icall, rc);
     135}
     136
     137static void taskman_i_am_ns(ipc_call_t *icall)
     138{
     139        DPRINTF("%s, %llu\n", __func__, icall->task_id);
     140        errno_t rc = EOK;
    141141
    142142        fibril_mutex_lock(&session_ns_mtx);
    143143        if (session_ns != NULL) {
    144                 rc = EEXISTS;
     144                rc = EEXIST;
    145145                goto finish;
    146146        }
     
    157157finish:
    158158        fibril_mutex_unlock(&session_ns_mtx);
    159         async_answer_0(iid, rc);
    160 }
    161 
    162 static void taskman_ctl_wait(ipc_callid_t iid, ipc_call_t *icall)
     159        async_answer_0(icall, rc);
     160}
     161
     162static void taskman_ctl_wait(ipc_call_t *icall)
    163163{
    164164        task_id_t id = (task_id_t)
    165             MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
    166         int flags = IPC_GET_ARG3(*icall);
    167         task_id_t waiter_id = icall->in_task_id;
    168 
    169         wait_for_task(id, flags, iid, waiter_id);
    170 }
    171 
    172 static void taskman_ctl_retval(ipc_callid_t iid, ipc_call_t *icall)
    173 {
    174         task_id_t sender = icall->in_task_id;
    175         int retval = IPC_GET_ARG1(*icall);
    176         bool wait_for_exit = IPC_GET_ARG2(*icall);
     165            MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall));
     166        int flags = ipc_get_arg3(icall);
     167        task_id_t waiter_id = icall->task_id;
     168
     169        wait_for_task(id, flags, icall, waiter_id);
     170}
     171
     172static void taskman_ctl_retval(ipc_call_t *icall)
     173{
     174        task_id_t sender = icall->task_id;
     175        int retval = ipc_get_arg1(icall);
     176        bool wait_for_exit = ipc_get_arg2(icall);
    177177
    178178        DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, sender, retval);
    179179
    180         int rc = task_set_retval(sender, retval, wait_for_exit);
    181         async_answer_0(iid, rc);
    182 }
    183 
    184 static void taskman_ctl_ev_callback(ipc_callid_t iid, ipc_call_t *icall)
    185 {
    186         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
    187 
    188         bool past_events = IPC_GET_ARG1(*icall);
     180        errno_t rc = task_set_retval(sender, retval, wait_for_exit);
     181        async_answer_0(icall, rc);
     182}
     183
     184static void taskman_ctl_ev_callback(ipc_call_t *icall)
     185{
     186        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id);
     187
     188        bool past_events = ipc_get_arg1(icall);
    189189
    190190        /* Atomic -- will be used for notifications only */
    191191        async_sess_t *sess = async_callback_receive(EXCHANGE_ATOMIC);
    192192        if (sess == NULL) {
    193                 async_answer_0(iid, ENOMEM);
    194                 return;
    195         }
    196 
    197         event_register_listener(icall->in_task_id, past_events, sess, iid);
    198 }
    199 
    200 static void task_exit_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    201 {
    202         task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
    203         exit_reason_t exit_reason = IPC_GET_ARG3(*icall);
     193                async_answer_0(icall, ENOMEM);
     194                return;
     195        }
     196
     197        event_register_listener(icall->task_id, past_events, sess, icall);
     198}
     199
     200static void task_exit_event(ipc_call_t *icall, void *arg)
     201{
     202        task_id_t id = MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall));
     203        exit_reason_t exit_reason = ipc_get_arg3(icall);
    204204        DPRINTF("%s:%i from %llu/%i\n", __func__, __LINE__, id, exit_reason);
    205205        task_terminated(id, exit_reason);
    206206}
    207207
    208 static void task_fault_event(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    209 {
    210         task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*icall), IPC_GET_ARG2(*icall));
     208static void task_fault_event(ipc_call_t *icall, void *arg)
     209{
     210        task_id_t id = MERGE_LOUP32(ipc_get_arg1(icall), ipc_get_arg2(icall));
    211211        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, id);
    212212        task_failed(id);
    213213}
    214214
    215 static void loader_callback(ipc_callid_t iid, ipc_call_t *icall)
    216 {
    217         DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->in_task_id);
     215static void loader_callback(ipc_call_t *icall)
     216{
     217        DPRINTF("%s:%i from %llu\n", __func__, __LINE__, icall->task_id);
    218218        // TODO check that loader is expected, would probably discard prodcons
    219219        //      scheme
     
    222222        sess_ref_t *sess_ref = malloc(sizeof(sess_ref_t));
    223223        if (sess_ref == NULL) {
    224                 async_answer_0(iid, ENOMEM);
     224                async_answer_0(icall, ENOMEM);
    225225        }
    226226
     
    228228        sess_ref->sess = async_callback_receive_start(EXCHANGE_ATOMIC, icall);
    229229        if (sess_ref->sess == NULL) {
    230                 async_answer_0(iid, EINVAL);
    231                 return;
    232         }
    233 
    234         async_answer_0(iid, EOK);
     230                async_answer_0(icall, EINVAL);
     231                return;
     232        }
     233
     234        async_answer_0(icall, EOK);
    235235
    236236        /* Notify spawners */
     
    239239}
    240240
    241 static bool handle_call(ipc_callid_t iid, ipc_call_t *icall)
    242 {
    243         switch (IPC_GET_IMETHOD(*icall)) {
     241static bool handle_call(ipc_call_t *icall)
     242{
     243        switch (ipc_get_imethod(icall)) {
    244244        case TASKMAN_NEW_TASK:
    245                 taskman_new_task(iid, icall);
     245                taskman_new_task(icall);
    246246                break;
    247247        case TASKMAN_I_AM_NS:
    248                 taskman_i_am_ns(iid, icall);
     248                taskman_i_am_ns(icall);
    249249                break;
    250250        case TASKMAN_WAIT:
    251                 taskman_ctl_wait(iid, icall);
     251                taskman_ctl_wait(icall);
    252252                break;
    253253        case TASKMAN_RETVAL:
    254                 taskman_ctl_retval(iid, icall);
     254                taskman_ctl_retval(icall);
    255255                break;
    256256        case TASKMAN_EVENT_CALLBACK:
    257                 taskman_ctl_ev_callback(iid, icall);
     257                taskman_ctl_ev_callback(icall);
    258258                break;
    259259        default:
     
    263263}
    264264
    265 static bool handle_implicit_call(ipc_callid_t iid, ipc_call_t *icall)
     265static bool handle_implicit_call(ipc_call_t *icall)
    266266{
    267267        /*DPRINTF("%s:%i %i(%i) from %llu\n", __func__, __LINE__,
     
    270270            icall->in_task_id);*/
    271271
    272         if (IPC_GET_IMETHOD(*icall) < IPC_FIRST_USER_METHOD) {
    273                 switch (IPC_GET_ARG1(*icall)) {
     272        if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) {
     273                switch (ipc_get_arg1(icall)) {
    274274                case TASKMAN_CONNECT_TO_NS:
    275                         connect_to_ns(iid, icall);
     275                        connect_to_ns(icall);
    276276                        break;
    277277                case TASKMAN_CONNECT_TO_LOADER:
    278                         connect_to_loader(iid, icall);
     278                        connect_to_loader(icall);
    279279                        break;
    280280                case TASKMAN_LOADER_CALLBACK:
    281                         loader_callback(iid, icall);
     281                        loader_callback(icall);
    282282                        break;
    283283                default:
     
    286286                }
    287287        } else {
    288                 return handle_call(iid, icall);
     288                return handle_call(icall);
    289289        }
    290290
     
    292292}
    293293
    294 static void implicit_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    295 {
    296         if (!handle_implicit_call(iid, icall)) {
    297                 async_answer_0(iid, ENOTSUP);
     294static void implicit_connection(ipc_call_t *icall, void *arg)
     295{
     296        if (!handle_implicit_call(icall)) {
     297                async_answer_0(icall, ENOTSUP);
    298298                return;
    299299        }
     
    301301        while (true) {
    302302                ipc_call_t call;
    303                 ipc_callid_t callid = async_get_call(&call);
    304 
    305                 if (!IPC_GET_IMETHOD(call)) {
     303
     304                if (!async_get_call(&call) || !ipc_get_imethod(&call)) {
    306305                        /* Client disconnected */
    307306                        break;
    308307                }
    309308
    310                 if (!handle_implicit_call(callid, &call)) {
    311                         async_answer_0(callid, ENOTSUP);
     309                if (!handle_implicit_call(&call)) {
     310                        async_answer_0(icall, ENOTSUP);
    312311                        break;
    313312                }
     
    315314}
    316315
    317 static void taskman_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
     316static void taskman_connection(ipc_call_t *icall, void *arg)
    318317{
    319318        /*
     
    324323         * "listening" on such connections.
    325324         */
    326         if (!handle_implicit_call(iid, icall)) {
    327                 /* If cannot handle connection requst, give up trying */
    328                 async_answer_0(iid, EHANGUP);
     325        if (!handle_implicit_call(icall)) {
     326                /* If cannot handle connection request, give up trying */
     327                async_answer_0(icall, EHANGUP);
    329328                return;
    330329        }
     
    339338        /* Initialization */
    340339        prodcons_initialize(&sess_queue);
    341         int rc = tasks_init();
     340        errno_t rc = tasks_init();
    342341        if (rc != EOK) {
    343342                return rc;
     
    368367        /* Start sysman server */
    369368        async_set_implicit_connection(implicit_connection);
    370         async_set_client_connection(taskman_connection);
     369        async_set_fallback_port_handler(taskman_connection, NULL);
    371370
    372371        printf(NAME ": Accepting connections\n");
Note: See TracChangeset for help on using the changeset viewer.