Changeset 984a9ba in mainline for uspace/srv/ns


Ignore:
Timestamp:
2018-07-05T09:34:09Z (7 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63d46341
Parents:
76f566d
Message:

do not expose the call capability handler from the async framework

Keep the call capability handler encapsulated within the async framework
and do not expose it explicitly via its API. Use the pointer to
ipc_call_t as the sole object identifying an IPC call in the code that
uses the async framework.

This plugs a major leak in the abstraction and also simplifies both the
async framework (slightly) and all IPC servers.

Location:
uspace/srv/ns
Files:
7 edited

Legend:

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

    r76f566d r984a9ba  
    4848        service_t service;
    4949        iface_t iface;
    50         cap_call_handle_t chandle;
    51         sysarg_t arg3;
     50        ipc_call_t call;
    5251} cs_req_t;
    5352
     
    7473 *
    7574 */
    76 void register_clonable(service_t service, sysarg_t phone, ipc_call_t *call,
    77     cap_call_handle_t chandle)
     75void register_clonable(service_t service, sysarg_t phone, ipc_call_t *call)
    7876{
    7977        link_t *req_link = list_first(&cs_req);
     
    8179                /* There was no pending connection request. */
    8280                printf("%s: Unexpected clonable server.\n", NAME);
    83                 async_answer_0(chandle, EBUSY);
     81                async_answer_0(call, EBUSY);
    8482                return;
    8583        }
     
    9189        assert(csr->service == SERVICE_LOADER);
    9290
    93         async_answer_0(chandle, EOK);
     91        async_answer_0(call, EOK);
    9492
    9593        async_sess_t *sess = async_callback_receive(EXCHANGE_SERIALIZE);
    9694        if (sess == NULL)
    97                 async_answer_0(chandle, EIO);
     95                async_answer_0(call, EIO);
    9896
    9997        async_exch_t *exch = async_exchange_begin(sess);
    100         async_forward_fast(csr->chandle, exch, csr->iface, csr->arg3, 0,
    101             IPC_FF_NONE);
     98        async_forward_fast(&csr->call, exch, csr->iface,
     99            IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE);
    102100        async_exchange_end(exch);
    103101
     
    108106/** Connect client to clonable service.
    109107 *
    110  * @param service  Service to be connected to.
    111  * @param iface    Interface to be connected to.
    112  * @param call     Pointer to call structure.
    113  * @param chandle  Call handle of the request.
     108 * @param service Service to be connected to.
     109 * @param iface   Interface to be connected to.
     110 * @param call    Pointer to call structure.
    114111 *
    115112 * @return Zero on success or a value from @ref errno.h.
    116113 *
    117114 */
    118 void connect_to_clonable(service_t service, iface_t iface, ipc_call_t *call,
    119     cap_call_handle_t chandle)
     115void connect_to_clonable(service_t service, iface_t iface, ipc_call_t *call)
    120116{
    121117        assert(service == SERVICE_LOADER);
     
    123119        cs_req_t *csr = malloc(sizeof(cs_req_t));
    124120        if (csr == NULL) {
    125                 async_answer_0(chandle, ENOMEM);
     121                async_answer_0(call, ENOMEM);
    126122                return;
    127123        }
     
    132128        if (rc != EOK) {
    133129                free(csr);
    134                 async_answer_0(chandle, rc);
     130                async_answer_0(call, rc);
    135131                return;
    136132        }
     
    139135        csr->service = service;
    140136        csr->iface = iface;
    141         csr->chandle = chandle;
    142         csr->arg3 = IPC_GET_ARG3(*call);
     137        csr->call = *call;
    143138
    144139        /*
  • uspace/srv/ns/clonable.h

    r76f566d r984a9ba  
    4242
    4343extern bool service_clonable(service_t);
    44 extern void register_clonable(service_t, sysarg_t, ipc_call_t *,
    45     cap_call_handle_t);
    46 extern void connect_to_clonable(service_t, iface_t, ipc_call_t *, cap_call_handle_t);
     44extern void register_clonable(service_t, sysarg_t, ipc_call_t *);
     45extern void connect_to_clonable(service_t, iface_t, ipc_call_t *);
    4746
    4847#endif
  • uspace/srv/ns/ns.c

    r76f566d r984a9ba  
    4949#include "task.h"
    5050
    51 static void ns_connection(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     51static void ns_connection(ipc_call_t *icall, void *arg)
    5252{
    5353        ipc_call_t call;
    54         cap_call_handle_t chandle;
    5554        iface_t iface;
    5655        service_t service;
     
    6362                 */
    6463                if (service_clonable(service)) {
    65                         connect_to_clonable(service, iface, icall, icall_handle);
     64                        connect_to_clonable(service, iface, icall);
    6665                } else {
    67                         connect_to_service(service, iface, icall, icall_handle);
     66                        connect_to_service(service, iface, icall);
    6867                }
    6968                return;
    7069        }
    7170
    72         async_answer_0(icall_handle, EOK);
     71        async_answer_0(icall, EOK);
    7372
    7473        while (true) {
    7574                process_pending_conn();
    7675
    77                 chandle = async_get_call(&call);
     76                async_get_call(&call);
    7877                if (!IPC_GET_IMETHOD(call))
    7978                        break;
     
    9493                         */
    9594                        if (service_clonable(service)) {
    96                                 register_clonable(service, phone, &call, chandle);
     95                                register_clonable(service, phone, &call);
    9796                                continue;
    9897                        } else {
     
    107106                        id = (task_id_t)
    108107                            MERGE_LOUP32(IPC_GET_ARG1(call), IPC_GET_ARG2(call));
    109                         wait_for_task(id, &call, chandle);
     108                        wait_for_task(id, &call);
    110109                        continue;
    111110                case NS_ID_INTRO:
     
    121120                }
    122121
    123                 async_answer_0(chandle, retval);
     122                async_answer_0(&call, retval);
    124123        }
    125124
  • uspace/srv/ns/service.c

    r76f566d r984a9ba  
    8989        service_t service;         /**< Service ID */
    9090        iface_t iface;             /**< Interface ID */
    91         cap_call_handle_t chandle; /**< Call handle waiting for the connection */
    92         sysarg_t arg3;             /**< Third argument */
     91        ipc_call_t call;           /**< Call waiting for the connection */
    9392} pending_conn_t;
    9493
     
    119118                hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link);
    120119                async_exch_t *exch = async_exchange_begin(hashed_service->sess);
    121                 async_forward_fast(pending->chandle, exch, pending->iface,
    122                     pending->arg3, 0, IPC_FF_NONE);
     120                async_forward_fast(&pending->call, exch, pending->iface,
     121                    IPC_GET_ARG3(pending->call), 0, IPC_FF_NONE);
    123122                async_exchange_end(exch);
    124123
     
    163162 * @param iface    Interface to be connected to.
    164163 * @param call     Pointer to call structure.
    165  * @param chandle  Call handle of the request.
    166164 *
    167165 * @return Zero on success or a value from @ref errno.h.
    168166 *
    169167 */
    170 void connect_to_service(service_t service, iface_t iface, ipc_call_t *call,
    171     cap_call_handle_t chandle)
    172 {
    173         sysarg_t arg3 = IPC_GET_ARG3(*call);
     168void connect_to_service(service_t service, iface_t iface, ipc_call_t *call)
     169{
    174170        sysarg_t flags = IPC_GET_ARG4(*call);
    175171        errno_t retval;
     
    189185                        pending->service = service;
    190186                        pending->iface = iface;
    191                         pending->chandle = chandle;
    192                         pending->arg3 = arg3;
     187                        pending->call = *call;
    193188
    194189                        list_append(&pending->link, &pending_conn);
     
    202197        hashed_service_t *hashed_service = hash_table_get_inst(link, hashed_service_t, link);
    203198        async_exch_t *exch = async_exchange_begin(hashed_service->sess);
    204         async_forward_fast(chandle, exch, iface, arg3, 0, IPC_FF_NONE);
     199        async_forward_fast(call, exch, iface, IPC_GET_ARG3(*call), 0, IPC_FF_NONE);
    205200        async_exchange_end(exch);
    206201        return;
    207202
    208203out:
    209         async_answer_0(chandle, retval);
     204        async_answer_0(call, retval);
    210205}
    211206
  • uspace/srv/ns/service.h

    r76f566d r984a9ba  
    4242
    4343extern errno_t register_service(service_t, sysarg_t, ipc_call_t *);
    44 extern void connect_to_service(service_t, iface_t, ipc_call_t *, cap_call_handle_t);
     44extern void connect_to_service(service_t, iface_t, ipc_call_t *);
    4545
    4646#endif
  • uspace/srv/ns/task.c

    r76f566d r984a9ba  
    145145typedef struct {
    146146        link_t link;
    147         task_id_t id;               ///< Task ID
    148         cap_call_handle_t chandle;  ///< Call handle waiting for the connection
     147        task_id_t id;     /**< Task ID */
     148        ipc_call_t call;  /**< Call waiting for the connection */
    149149} pending_wait_t;
    150150
     
    184184                texit = ht->have_rval ? TASK_EXIT_NORMAL :
    185185                    TASK_EXIT_UNEXPECTED;
    186                 async_answer_2(pr->chandle, EOK, texit, ht->retval);
     186                async_answer_2(&pr->call, EOK, texit, ht->retval);
    187187
    188188                list_remove(&pr->link);
     
    192192}
    193193
    194 void wait_for_task(task_id_t id, ipc_call_t *call, cap_call_handle_t chandle)
     194void wait_for_task(task_id_t id, ipc_call_t *call)
    195195{
    196196        ht_link_t *link = hash_table_find(&task_hash_table, &id);
     
    200200        if (ht == NULL) {
    201201                /* No such task exists. */
    202                 async_answer_0(chandle, ENOENT);
     202                async_answer_0(call, ENOENT);
    203203                return;
    204204        }
     
    207207                task_exit_t texit = ht->have_rval ? TASK_EXIT_NORMAL :
    208208                    TASK_EXIT_UNEXPECTED;
    209                 async_answer_2(chandle, EOK, texit, ht->retval);
     209                async_answer_2(call, EOK, texit, ht->retval);
    210210                return;
    211211        }
     
    215215            (pending_wait_t *) malloc(sizeof(pending_wait_t));
    216216        if (!pr) {
    217                 async_answer_0(chandle, ENOMEM);
     217                async_answer_0(call, ENOMEM);
    218218                return;
    219219        }
     
    221221        link_initialize(&pr->link);
    222222        pr->id = id;
    223         pr->chandle = chandle;
     223        pr->call = *call;
    224224        list_append(&pr->link, &pending_wait);
    225225}
  • uspace/srv/ns/task.h

    r76f566d r984a9ba  
    4040extern void process_pending_wait(void);
    4141
    42 extern void wait_for_task(task_id_t, ipc_call_t *, cap_call_handle_t);
     42extern void wait_for_task(task_id_t, ipc_call_t *);
    4343
    4444extern errno_t ns_task_id_intro(ipc_call_t *);
    4545extern errno_t ns_task_disconnect(ipc_call_t *);
    4646extern errno_t ns_task_retval(ipc_call_t *);
    47 
    4847
    4948#endif
Note: See TracChangeset for help on using the changeset viewer.