Changeset b2f05e2 in mainline


Ignore:
Timestamp:
2020-01-09T06:27:27Z (4 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
8a74512
Parents:
33c5626
git-author:
Matthieu Riolo <matthieu.riolo@…> (2020-01-09 02:56:12)
git-committer:
Matthieu Riolo <matthieu.riolo@…> (2020-01-09 06:27:27)
Message:

Clean up taskman fallback handler

In the previous commits the handler has corrected but it left
behind a mess. This commit cleans up the code by using the
simplified function from async library

Location:
uspace
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/taskman.c

    r33c5626 rb2f05e2  
    132132{
    133133        async_exch_t *exch = taskman_exchange_begin();
    134         errno_t rc = async_connect_to_me(exch, INTERFACE_ANY, TASKMAN_LOADER_CALLBACK, 0);
     134        aid_t req = async_send_0(exch, TASKMAN_I_AM_LOADER, NULL);
     135
     136        errno_t rc = async_connect_to_me(exch, INTERFACE_ANY, 0, 0);
    135137        taskman_exchange_end(exch);
    136138
    137         return rc;
     139        if (rc != EOK) {
     140                async_forget(req);
     141                return rc;
     142        }
     143
     144        errno_t retval;
     145        async_wait_for(req, &retval);
     146        return retval;
    138147}
    139148
  • uspace/lib/c/include/ipc/taskman.h

    r33c5626 rb2f05e2  
    4343        TASKMAN_EVENT_CALLBACK,
    4444        TASKMAN_NEW_TASK,
     45
    4546        TASKMAN_I_AM_NS,
     47        TASKMAN_I_AM_LOADER,
    4648
    4749        TASKMAN_CONNECT_TO_NS,
    48         TASKMAN_CONNECT_TO_LOADER,
    49         TASKMAN_LOADER_CALLBACK
     50        TASKMAN_CONNECT_TO_LOADER
    5051} taskman_request_t;
    5152
  • uspace/srv/taskman/main.c

    r33c5626 rb2f05e2  
    222222}
    223223
    224 static void loader_callback(ipc_call_t *icall)
     224static void taskman_i_am_loader(ipc_call_t *icall)
    225225{
    226226        DPRINTF("%s:%d from %" PRIu64 "\n", __func__, __LINE__, icall->task_id);
     
    236236
    237237        /* Create callback connection */
    238         sess_ref->sess = async_callback_receive_start(EXCHANGE_ATOMIC, icall);
    239         if (sess_ref->sess == NULL) {
    240                 async_answer_0(icall, EINVAL);
    241                 return;
    242         }
    243 
    244         async_answer_0(icall, EOK);
     238        sess_ref->sess = async_callback_receive(EXCHANGE_ATOMIC);
    245239
    246240        /* Notify spawners */
     
    251245static void taskman_connection(ipc_call_t *icall, void *arg)
    252246{
    253         /* handle new incoming calls */
    254         if (ipc_get_imethod(icall) == IPC_M_CONNECT_ME_TO) {
    255                 switch (ipc_get_arg2(icall)) {
    256                 case TASKMAN_NEW_TASK:
    257                         taskman_new_task(icall);
    258                         break;
    259                 case TASKMAN_CONNECT_TO_NS:
    260                         connect_to_ns(icall);
    261                         return;
    262                 case TASKMAN_CONNECT_TO_LOADER:
    263                         connect_to_loader(icall);
    264                         return;
    265                 default:
    266                         DPRINTF("%s:%d from %" PRIu64 "/%" SCNuPTR "/%" SCNuPTR "/%" SCNuPTR "\n",
    267                             __func__, __LINE__,
    268                             icall->task_id, ipc_get_imethod(icall),
    269                             ipc_get_arg1(icall), ipc_get_arg2(icall));
    270                         async_answer_0(icall, ENOTSUP);
    271                         return;
    272                 }
     247        /* handle new incoming IPC_M_CONNECT_ME_TO calls */
     248        switch (ipc_get_arg2(icall)) {
     249        case TASKMAN_NEW_TASK:
     250                taskman_new_task(icall);
     251                break;
     252        case TASKMAN_CONNECT_TO_NS:
     253                connect_to_ns(icall);
     254                break;
     255        case TASKMAN_CONNECT_TO_LOADER:
     256                connect_to_loader(icall);
     257                break;
     258        default:
     259                DPRINTF("%s:%d from %" PRIu64 "/%" SCNuPTR "/%" SCNuPTR "/%" SCNuPTR "\n",
     260                    __func__, __LINE__,
     261                    icall->task_id, ipc_get_imethod(icall),
     262                    ipc_get_arg1(icall), ipc_get_arg2(icall));
     263                async_answer_0(icall, ENOTSUP);
     264                return;
    273265        }
    274266
     
    277269                ipc_call_t call;
    278270
    279                 if (!async_get_call(&call)) {
     271                if (!async_get_call(&call) || !ipc_get_imethod(&call)) {
    280272                        /* Client disconnected */
    281273                        DPRINTF("%s:%d client disconnected\n", __func__, __LINE__);
    282                         return;
     274                        break;
    283275                }
    284276
     
    287279                        taskman_i_am_ns(&call);
    288280                        break;
     281                case TASKMAN_I_AM_LOADER:
     282                        taskman_i_am_loader(&call);
     283                        break;
    289284                case TASKMAN_WAIT:
    290285                        taskman_ctl_wait(&call);
     
    296291                        taskman_ctl_ev_callback(&call);
    297292                        break;
    298                 case IPC_M_CONNECT_TO_ME:
    299                         if (ipc_get_arg2(&call) == TASKMAN_LOADER_CALLBACK) {
    300                                 loader_callback(&call);
    301                                 break;
    302                         }
    303                         goto FALLTHROUGH_DEFAULT;
    304                         break;
    305                 FALLTHROUGH_DEFAULT:
    306293                default:
    307294                        DPRINTF("%s:%d from %" PRIu64 "/%" SCNuPTR "/%" SCNuPTR "/%" SCNuPTR "\n",
Note: See TracChangeset for help on using the changeset viewer.