Changeset a46e56b in mainline for uspace/lib/hound/src/protocol.c


Ignore:
Timestamp:
2018-03-22T06:49:35Z (7 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
77f0a1d
Parents:
3e242d2
git-author:
Jakub Jermar <jakub@…> (2018-03-21 23:29:06)
git-committer:
Jakub Jermar <jakub@…> (2018-03-22 06:49:35)
Message:

Prefer handle over ID in naming handle variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/src/protocol.c

    r3e242d2 ra46e56b  
    384384 * @param arg (unused)
    385385 */
    386 void hound_connection_handler(cap_call_handle_t iid, ipc_call_t *icall, void *arg)
     386void hound_connection_handler(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
    387387{
    388388        hound_context_id_t id;
     
    394394        /* Accept connection if there is a valid iface*/
    395395        if (server_iface) {
    396                 async_answer_0(iid, EOK);
     396                async_answer_0(icall_handle, EOK);
    397397        } else {
    398                 async_answer_0(iid, ENOTSUP);
     398                async_answer_0(icall_handle, ENOTSUP);
    399399                return;
    400400        }
     
    402402        while (1) {
    403403                ipc_call_t call;
    404                 cap_call_handle_t callid = async_get_call(&call);
     404                cap_call_handle_t chandle = async_get_call(&call);
    405405                switch (IPC_GET_IMETHOD(call)) {
    406406                case IPC_M_HOUND_CONTEXT_REGISTER:
    407407                        /* check interface functions */
    408408                        if (!server_iface || !server_iface->add_context) {
    409                                 async_answer_0(callid, ENOTSUP);
     409                                async_answer_0(chandle, ENOTSUP);
    410410                                break;
    411411                        }
     
    416416                        ret = async_data_write_accept(&name, true, 0, 0, 0, 0);
    417417                        if (ret != EOK) {
    418                                 async_answer_0(callid, ret);
     418                                async_answer_0(chandle, ret);
    419419                                break;
    420420                        }
     
    426426                        free(name);
    427427                        if (ret != EOK) {
    428                                 async_answer_0(callid, ret);
     428                                async_answer_0(chandle, ret);
    429429                        } else {
    430                                 async_answer_1(callid, EOK, CAP_HANDLE_RAW(id));
     430                                async_answer_1(chandle, EOK, CAP_HANDLE_RAW(id));
    431431                        }
    432432                        break;
     
    434434                        /* check interface functions */
    435435                        if (!server_iface || !server_iface->rem_context) {
    436                                 async_answer_0(callid, ENOTSUP);
     436                                async_answer_0(chandle, ENOTSUP);
    437437                                break;
    438438                        }
     
    442442                        ret = server_iface->rem_context(server_iface->server,
    443443                            id);
    444                         async_answer_0(callid, ret);
     444                        async_answer_0(chandle, ret);
    445445                        break;
    446446                case IPC_M_HOUND_GET_LIST:
    447447                        /* check interface functions */
    448448                        if (!server_iface || !server_iface->get_list) {
    449                                 async_answer_0(callid, ENOTSUP);
     449                                async_answer_0(chandle, ENOTSUP);
    450450                                break;
    451451                        }
     
    475475                        if (count && !sizes)
    476476                                ret = ENOMEM;
    477                         async_answer_1(callid, ret, count);
     477                        async_answer_1(chandle, ret, count);
    478478
    479479                        /* We are done */
     
    509509                        /* check interface functions */
    510510                        if (!server_iface || !server_iface->connect) {
    511                                 async_answer_0(callid, ENOTSUP);
     511                                async_answer_0(chandle, ENOTSUP);
    512512                                break;
    513513                        }
     
    529529                        free(source);
    530530                        free(sink);
    531                         async_answer_0(callid, ret);
     531                        async_answer_0(chandle, ret);
    532532                        break;
    533533                case IPC_M_HOUND_DISCONNECT:
    534534                        /* check interface functions */
    535535                        if (!server_iface || !server_iface->disconnect) {
    536                                 async_answer_0(callid, ENOTSUP);
     536                                async_answer_0(chandle, ENOTSUP);
    537537                                break;
    538538                        }
     
    553553                        free(source);
    554554                        free(sink);
    555                         async_answer_0(callid, ret);
     555                        async_answer_0(chandle, ret);
    556556                        break;
    557557                case IPC_M_HOUND_STREAM_ENTER:
     
    560560                            || !server_iface->add_stream
    561561                            || !server_iface->rem_stream) {
    562                                 async_answer_0(callid, ENOTSUP);
     562                                async_answer_0(chandle, ENOTSUP);
    563563                                break;
    564564                        }
     
    579579                            id, flags, f, bsize, &stream);
    580580                        if (ret != EOK) {
    581                                 async_answer_0(callid, ret);
     581                                async_answer_0(chandle, ret);
    582582                                break;
    583583                        }
     
    586586                        if (rec) {
    587587                                if(server_iface->stream_data_read) {
    588                                         async_answer_0(callid, EOK);
     588                                        async_answer_0(chandle, EOK);
    589589                                        /* start answering read calls */
    590590                                        hound_server_write_data(stream);
     
    592592                                            server_iface->server, stream);
    593593                                } else {
    594                                         async_answer_0(callid, ENOTSUP);
     594                                        async_answer_0(chandle, ENOTSUP);
    595595                                }
    596596                        } else {
    597597                                if (server_iface->stream_data_write) {
    598                                         async_answer_0(callid, EOK);
     598                                        async_answer_0(chandle, EOK);
    599599                                        /* accept write calls */
    600600                                        hound_server_read_data(stream);
     
    602602                                            server_iface->server, stream);
    603603                                } else {
    604                                         async_answer_0(callid, ENOTSUP);
     604                                        async_answer_0(chandle, ENOTSUP);
    605605                                }
    606606                        }
     
    609609                case IPC_M_HOUND_STREAM_DRAIN:
    610610                        /* Stream exit/drain is only allowed in stream context*/
    611                         async_answer_0(callid, EINVAL);
     611                        async_answer_0(chandle, EINVAL);
    612612                        break;
    613613                default:
    614                         async_answer_0(callid, ENOTSUP);
     614                        async_answer_0(chandle, ENOTSUP);
    615615                        return;
    616616                }
     
    624624static void hound_server_read_data(void *stream)
    625625{
    626         cap_call_handle_t callid;
     626        cap_call_handle_t chandle;
    627627        ipc_call_t call;
    628628        size_t size = 0;
    629629        errno_t ret_answer = EOK;
    630630        /* accept data write or drain */
    631         while (async_data_write_receive_call(&callid, &call, &size)
     631        while (async_data_write_receive_call(&chandle, &call, &size)
    632632            || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
    633633                /* check drain first */
     
    636636                        if (server_iface->drain_stream)
    637637                                ret = server_iface->drain_stream(stream);
    638                         async_answer_0(callid, ret);
     638                        async_answer_0(chandle, ret);
    639639                        continue;
    640640                }
     
    642642                /* there was an error last time */
    643643                if (ret_answer != EOK) {
    644                         async_answer_0(callid, ret_answer);
     644                        async_answer_0(chandle, ret_answer);
    645645                        continue;
    646646                }
     
    648648                char *buffer = malloc(size);
    649649                if (!buffer) {
    650                         async_answer_0(callid, ENOMEM);
     650                        async_answer_0(chandle, ENOMEM);
    651651                        continue;
    652652                }
    653                 const errno_t ret = async_data_write_finalize(callid, buffer, size);
     653                const errno_t ret = async_data_write_finalize(chandle, buffer, size);
    654654                if (ret == EOK) {
    655655                        /* push data to stream */
     
    661661            ? EOK : EINVAL;
    662662
    663         async_answer_0(callid, ret);
     663        async_answer_0(chandle, ret);
    664664}
    665665
     
    671671{
    672672
    673         cap_call_handle_t callid;
     673        cap_call_handle_t chandle;
    674674        ipc_call_t call;
    675675        size_t size = 0;
    676676        errno_t ret_answer = EOK;
    677677        /* accept data read and drain */
    678         while (async_data_read_receive_call(&callid, &call, &size)
     678        while (async_data_read_receive_call(&chandle, &call, &size)
    679679            || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
    680680                /* drain does not make much sense but it is allowed */
     
    683683                        if (server_iface->drain_stream)
    684684                                ret = server_iface->drain_stream(stream);
    685                         async_answer_0(callid, ret);
     685                        async_answer_0(chandle, ret);
    686686                        continue;
    687687                }
    688688                /* there was an error last time */
    689689                if (ret_answer != EOK) {
    690                         async_answer_0(callid, ret_answer);
     690                        async_answer_0(chandle, ret_answer);
    691691                        continue;
    692692                }
    693693                char *buffer = malloc(size);
    694694                if (!buffer) {
    695                         async_answer_0(callid, ENOMEM);
     695                        async_answer_0(chandle, ENOMEM);
    696696                        continue;
    697697                }
     
    699699                if (ret == EOK) {
    700700                        ret_answer =
    701                             async_data_read_finalize(callid, buffer, size);
     701                            async_data_read_finalize(chandle, buffer, size);
    702702                }
    703703        }
     
    705705            ? EOK : EINVAL;
    706706
    707         async_answer_0(callid, ret);
     707        async_answer_0(chandle, ret);
    708708}
    709709
Note: See TracChangeset for help on using the changeset viewer.