Ignore:
Timestamp:
2018-07-05T09:34:09Z (6 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_audio_mixer.c

    r76f566d r984a9ba  
    203203 * SERVER SIDE
    204204 */
    205 static void remote_audio_mixer_get_info(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *);
    206 static void remote_audio_mixer_get_item_info(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *);
    207 static void remote_audio_mixer_get_item_level(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *);
    208 static void remote_audio_mixer_set_item_level(ddf_fun_t *, void *, cap_call_handle_t, ipc_call_t *);
     205static void remote_audio_mixer_get_info(ddf_fun_t *, void *, ipc_call_t *);
     206static void remote_audio_mixer_get_item_info(ddf_fun_t *, void *, ipc_call_t *);
     207static void remote_audio_mixer_get_item_level(ddf_fun_t *, void *, ipc_call_t *);
     208static void remote_audio_mixer_set_item_level(ddf_fun_t *, void *, ipc_call_t *);
    209209
    210210/** Remote audio mixer interface operations. */
     
    222222};
    223223
    224 void remote_audio_mixer_get_info(
    225     ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call)
     224void remote_audio_mixer_get_info(ddf_fun_t *fun, void *iface, ipc_call_t *icall)
    226225{
    227226        audio_mixer_iface_t *mixer_iface = iface;
    228227
    229228        if (!mixer_iface->get_info) {
    230                 async_answer_0(chandle, ENOTSUP);
     229                async_answer_0(icall, ENOTSUP);
    231230                return;
    232231        }
     232
    233233        const char *name = NULL;
    234234        unsigned items = 0;
    235235        const errno_t ret = mixer_iface->get_info(fun, &name, &items);
    236236        const size_t name_size = name ? str_size(name) + 1 : 0;
    237         async_answer_2(chandle, ret, name_size, items);
     237        async_answer_2(icall, ret, name_size, items);
     238
    238239        /* Send the name. */
    239240        if (ret == EOK && name_size > 0) {
     241                ipc_call_t call;
    240242                size_t size;
    241                 cap_call_handle_t name_id;
    242                 if (!async_data_read_receive(&name_id, &size)) {
    243                         async_answer_0(name_id, EPARTY);
     243                if (!async_data_read_receive(&call, &size)) {
     244                        async_answer_0(&call, EPARTY);
    244245                        return;
    245246                }
     247
    246248                if (size != name_size) {
    247                         async_answer_0(name_id, ELIMIT);
     249                        async_answer_0(&call, ELIMIT);
    248250                        return;
    249251                }
    250                 async_data_read_finalize(name_id, name, name_size);
    251         }
    252 }
    253 
    254 void remote_audio_mixer_get_item_info(
    255     ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call)
     252
     253                async_data_read_finalize(&call, name, name_size);
     254        }
     255}
     256
     257void remote_audio_mixer_get_item_info(ddf_fun_t *fun, void *iface,
     258    ipc_call_t *icall)
    256259{
    257260        audio_mixer_iface_t *mixer_iface = iface;
    258261
    259262        if (!mixer_iface->get_item_info) {
    260                 async_answer_0(chandle, ENOTSUP);
     263                async_answer_0(icall, ENOTSUP);
    261264                return;
    262265        }
    263266
    264         const unsigned item = DEV_IPC_GET_ARG1(*call);
     267        const unsigned item = DEV_IPC_GET_ARG1(*icall);
    265268        const char *name = NULL;
    266269        unsigned values = 0;
    267270        const errno_t ret = mixer_iface->get_item_info(fun, item, &name, &values);
    268271        const size_t name_size = name ? str_size(name) + 1 : 0;
    269         async_answer_2(chandle, ret, name_size, values);
     272        async_answer_2(icall, ret, name_size, values);
     273
    270274        /* Send the name. */
    271275        if (ret == EOK && name_size > 0) {
     276                ipc_call_t call;
    272277                size_t size;
    273                 cap_call_handle_t name_id;
    274                 if (!async_data_read_receive(&name_id, &size)) {
    275                         async_answer_0(name_id, EPARTY);
     278                if (!async_data_read_receive(&call, &size)) {
     279                        async_answer_0(&call, EPARTY);
    276280                        return;
    277281                }
     282
    278283                if (size != name_size) {
    279                         async_answer_0(name_id, ELIMIT);
     284                        async_answer_0(&call, ELIMIT);
    280285                        return;
    281286                }
    282                 async_data_read_finalize(name_id, name, name_size);
    283         }
    284 }
    285 
    286 void remote_audio_mixer_set_item_level(
    287     ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call)
     287
     288                async_data_read_finalize(&call, name, name_size);
     289        }
     290}
     291
     292void remote_audio_mixer_set_item_level(ddf_fun_t *fun, void *iface,
     293    ipc_call_t *icall)
    288294{
    289295        audio_mixer_iface_t *mixer_iface = iface;
    290296
    291297        if (!mixer_iface->set_item_level) {
    292                 async_answer_0(chandle, ENOTSUP);
     298                async_answer_0(icall, ENOTSUP);
    293299                return;
    294300        }
    295         const unsigned item = DEV_IPC_GET_ARG1(*call);
    296         const unsigned value = DEV_IPC_GET_ARG2(*call);
     301
     302        const unsigned item = DEV_IPC_GET_ARG1(*icall);
     303        const unsigned value = DEV_IPC_GET_ARG2(*icall);
    297304        const errno_t ret = mixer_iface->set_item_level(fun, item, value);
    298         async_answer_0(chandle, ret);
    299 }
    300 
    301 void remote_audio_mixer_get_item_level(
    302     ddf_fun_t *fun, void *iface, cap_call_handle_t chandle, ipc_call_t *call)
     305        async_answer_0(icall, ret);
     306}
     307
     308void remote_audio_mixer_get_item_level(ddf_fun_t *fun, void *iface,
     309    ipc_call_t *icall)
    303310{
    304311        audio_mixer_iface_t *mixer_iface = iface;
    305312
    306313        if (!mixer_iface->get_item_level) {
    307                 async_answer_0(chandle, ENOTSUP);
     314                async_answer_0(icall, ENOTSUP);
    308315                return;
    309316        }
    310         const unsigned item = DEV_IPC_GET_ARG1(*call);
     317
     318        const unsigned item = DEV_IPC_GET_ARG1(*icall);
    311319        unsigned current = 0;
    312320        const errno_t ret =
    313321            mixer_iface->get_item_level(fun, item, &current);
    314         async_answer_1(chandle, ret, current);
     322        async_answer_1(icall, ret, current);
    315323}
    316324
Note: See TracChangeset for help on using the changeset viewer.