Changeset 984a9ba in mainline for uspace/lib/c/generic/inetping.c


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/c/generic/inetping.c

    r76f566d r984a9ba  
    3838#include <str.h>
    3939
    40 static void inetping_cb_conn(cap_call_handle_t, ipc_call_t *, void *);
    41 static void inetping_ev_recv(cap_call_handle_t, ipc_call_t *);
     40static void inetping_cb_conn(ipc_call_t *, void *);
     41static void inetping_ev_recv(ipc_call_t *);
    4242
    4343static async_sess_t *inetping_sess = NULL;
     
    150150}
    151151
    152 static void inetping_ev_recv(cap_call_handle_t icall_handle, ipc_call_t *icall)
     152static void inetping_ev_recv(ipc_call_t *icall)
    153153{
    154154        inetping_sdu_t sdu;
     
    156156        sdu.seq_no = IPC_GET_ARG1(*icall);
    157157
    158         cap_call_handle_t chandle;
     158        ipc_call_t call;
    159159        size_t size;
    160         if (!async_data_write_receive(&chandle, &size)) {
    161                 async_answer_0(chandle, EREFUSED);
    162                 async_answer_0(icall_handle, EREFUSED);
     160        if (!async_data_write_receive(&call, &size)) {
     161                async_answer_0(&call, EREFUSED);
     162                async_answer_0(icall, EREFUSED);
    163163                return;
    164164        }
    165165
    166166        if (size != sizeof(sdu.src)) {
    167                 async_answer_0(chandle, EINVAL);
    168                 async_answer_0(icall_handle, EINVAL);
    169                 return;
    170         }
    171 
    172         errno_t rc = async_data_write_finalize(chandle, &sdu.src, size);
    173         if (rc != EOK) {
    174                 async_answer_0(chandle, rc);
    175                 async_answer_0(icall_handle, rc);
    176                 return;
    177         }
    178 
    179         if (!async_data_write_receive(&chandle, &size)) {
    180                 async_answer_0(chandle, EREFUSED);
    181                 async_answer_0(icall_handle, EREFUSED);
     167                async_answer_0(&call, EINVAL);
     168                async_answer_0(icall, EINVAL);
     169                return;
     170        }
     171
     172        errno_t rc = async_data_write_finalize(&call, &sdu.src, size);
     173        if (rc != EOK) {
     174                async_answer_0(&call, rc);
     175                async_answer_0(icall, rc);
     176                return;
     177        }
     178
     179        if (!async_data_write_receive(&call, &size)) {
     180                async_answer_0(&call, EREFUSED);
     181                async_answer_0(icall, EREFUSED);
    182182                return;
    183183        }
    184184
    185185        if (size != sizeof(sdu.dest)) {
    186                 async_answer_0(chandle, EINVAL);
    187                 async_answer_0(icall_handle, EINVAL);
    188                 return;
    189         }
    190 
    191         rc = async_data_write_finalize(chandle, &sdu.dest, size);
    192         if (rc != EOK) {
    193                 async_answer_0(chandle, rc);
    194                 async_answer_0(icall_handle, rc);
     186                async_answer_0(&call, EINVAL);
     187                async_answer_0(icall, EINVAL);
     188                return;
     189        }
     190
     191        rc = async_data_write_finalize(&call, &sdu.dest, size);
     192        if (rc != EOK) {
     193                async_answer_0(&call, rc);
     194                async_answer_0(icall, rc);
    195195                return;
    196196        }
     
    198198        rc = async_data_write_accept(&sdu.data, false, 0, 0, 0, &sdu.size);
    199199        if (rc != EOK) {
    200                 async_answer_0(icall_handle, rc);
     200                async_answer_0(icall, rc);
    201201                return;
    202202        }
     
    204204        rc = inetping_ev_ops->recv(&sdu);
    205205        free(sdu.data);
    206         async_answer_0(icall_handle, rc);
    207 }
    208 
    209 static void inetping_cb_conn(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     206        async_answer_0(icall, rc);
     207}
     208
     209static void inetping_cb_conn(ipc_call_t *icall, void *arg)
    210210{
    211211        while (true) {
    212212                ipc_call_t call;
    213                 cap_call_handle_t chandle = async_get_call(&call);
     213                async_get_call(&call);
    214214
    215215                if (!IPC_GET_IMETHOD(call)) {
     
    220220                switch (IPC_GET_IMETHOD(call)) {
    221221                case INETPING_EV_RECV:
    222                         inetping_ev_recv(chandle, &call);
     222                        inetping_ev_recv(&call);
    223223                        break;
    224224                default:
    225                         async_answer_0(chandle, ENOTSUP);
     225                        async_answer_0(&call, ENOTSUP);
    226226                }
    227227        }
Note: See TracChangeset for help on using the changeset viewer.