Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 061274f in mainline


Ignore:
Timestamp:
2018-06-28T11:09:38Z (2 years ago)
Author:
Martin Decky <martin@…>
Branches:
master
Children:
82453b29
Parents:
62c4297
Message:

simplify async framework internals

Do not duplicitly store or pass the cap_call_handle_t if we have the
ipc_call_t structure around which already contains the call capability
handle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async/server.c

    r62c4297 r061274f  
    134134        link_t link;
    135135
    136         cap_call_handle_t chandle;
    137136        ipc_call_t call;
    138137} msg_t;
     
    165164        /** Messages that should be delivered to this fibril. */
    166165        list_t msg_queue;
    167 
    168         /** Identification of the opening call. */
    169         cap_call_handle_t chandle;
    170166
    171167        /** Call data of the opening call. */
     
    413409        client_t *client = async_client_get(fibril_connection->in_task_id, true);
    414410        if (!client) {
    415                 ipc_answer_0(fibril_connection->chandle, ENOMEM);
     411                ipc_answer_0(fibril_connection->call.cap_handle, ENOMEM);
    416412                return 0;
    417413        }
     
    422418         * Call the connection handler function.
    423419         */
    424         fibril_connection->handler(fibril_connection->chandle,
     420        fibril_connection->handler(fibril_connection->call.cap_handle,
    425421            &fibril_connection->call, fibril_connection->data);
    426422
     
    449445
    450446                list_remove(&msg->link);
    451                 ipc_answer_0(msg->chandle, EHANGUP);
     447                ipc_answer_0(msg->call.cap_handle, EHANGUP);
    452448                free(msg);
    453449        }
     
    472468 * @param in_task_id     Identification of the incoming connection.
    473469 * @param in_phone_hash  Identification of the incoming connection.
    474  * @param chandle        Handle of the opening IPC_M_CONNECT_ME_TO call.
    475  *                       If chandle is CAP_NIL, the connection was opened by
    476  *                       accepting the IPC_M_CONNECT_TO_ME call and this
    477  *                       function is called directly by the server.
    478  * @param call           Call data of the opening call.
     470 * @param call           Call data of the opening call. If call is NULL,
     471 *                       the connection was opened by accepting the
     472 *                       IPC_M_CONNECT_TO_ME call and this function is
     473 *                       called directly by the server.
    479474 * @param handler        Connection handler.
    480475 * @param data           Client argument to pass to the connection handler.
     
    484479 */
    485480static fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash,
    486     cap_call_handle_t chandle, ipc_call_t *call, async_port_handler_t handler,
    487     void *data)
     481    ipc_call_t *call, async_port_handler_t handler, void *data)
    488482{
    489483        connection_t *conn = malloc(sizeof(*conn));
    490484        if (!conn) {
    491                 if (chandle != CAP_NIL)
    492                         ipc_answer_0(chandle, ENOMEM);
     485                if (call)
     486                        ipc_answer_0(call->cap_handle, ENOMEM);
    493487
    494488                return (uintptr_t) NULL;
     
    498492        conn->in_phone_hash = in_phone_hash;
    499493        list_initialize(&conn->msg_queue);
    500         conn->chandle = chandle;
    501494        conn->close_chandle = CAP_NIL;
    502495        conn->handler = handler;
     
    505498        if (call)
    506499                conn->call = *call;
     500        else
     501                conn->call.cap_handle = CAP_NIL;
    507502
    508503        /* We will activate the fibril ASAP */
     
    513508                free(conn);
    514509
    515                 if (chandle != CAP_NIL)
    516                         ipc_answer_0(chandle, ENOMEM);
     510                if (call)
     511                        ipc_answer_0(call->cap_handle, ENOMEM);
    517512
    518513                return (uintptr_t) NULL;
     
    569564        sysarg_t phone_hash = IPC_GET_ARG5(answer);
    570565        fid_t fid = async_new_connection(answer.in_task_id, phone_hash,
    571             CAP_NIL, NULL, handler, data);
     566            NULL, handler, data);
    572567        if (fid == (uintptr_t) NULL)
    573568                return ENOMEM;
     
    638633 * timeouts are unregistered.
    639634 *
    640  * @param chandle  Handle of the incoming call.
    641  * @param call     Data of the incoming call.
     635 * @param call Data of the incoming call.
    642636 *
    643637 * @return False if the call doesn't match any connection.
     
    645639 *
    646640 */
    647 static bool route_call(cap_call_handle_t chandle, ipc_call_t *call)
     641static bool route_call(ipc_call_t *call)
    648642{
    649643        assert(call);
     
    668662        }
    669663
    670         msg->chandle = chandle;
    671664        msg->call = *call;
    672665        list_append(&msg->link, &conn->msg_queue);
    673666
    674667        if (IPC_GET_IMETHOD(*call) == IPC_M_PHONE_HUNGUP)
    675                 conn->close_chandle = chandle;
     668                conn->close_chandle = call->cap_handle;
    676669
    677670        /* If the connection fibril is waiting for an event, activate it */
     
    10421035        list_remove(&msg->link);
    10431036
    1044         cap_call_handle_t chandle = msg->chandle;
     1037        cap_call_handle_t chandle = msg->call.cap_handle;
    10451038        *call = msg->call;
    10461039        free(msg);
     
    10891082 * Otherwise the call is routed to its connection fibril.
    10901083 *
    1091  * @param chandle  Handle of the incoming call.
    1092  * @param call     Data of the incoming call.
    1093  *
    1094  */
    1095 static void handle_call(cap_call_handle_t chandle, ipc_call_t *call)
     1084 * @param call Data of the incoming call.
     1085 *
     1086 */
     1087static void handle_call(ipc_call_t *call)
    10961088{
    10971089        assert(call);
     
    11001092                return;
    11011093
    1102         if (chandle == CAP_NIL) {
     1094        if (call->cap_handle == CAP_NIL) {
    11031095                if (call->flags & IPC_CALL_NOTIF) {
    11041096                        /* Kernel notification */
     
    11181110                    async_get_port_handler(iface, 0, &data);
    11191111
    1120                 async_new_connection(call->in_task_id, in_phone_hash, chandle,
    1121                     call, handler, data);
     1112                async_new_connection(call->in_task_id, in_phone_hash, call,
     1113                    handler, data);
    11221114                return;
    11231115        }
    11241116
    11251117        /* Try to route the call through the connection hash table */
    1126         if (route_call(chandle, call))
     1118        if (route_call(call))
    11271119                return;
    11281120
    11291121        /* Unknown call from unknown phone - hang it up */
    1130         ipc_answer_0(chandle, EHANGUP);
     1122        ipc_answer_0(call->cap_handle, EHANGUP);
    11311123}
    11321124
     
    12091201
    12101202                assert(rc == EOK);
    1211                 handle_call(call.cap_handle, &call);
     1203                handle_call(&call);
    12121204        }
    12131205
Note: See TracChangeset for help on using the changeset viewer.