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/srv/hid/compositor/compositor.c

    r76f566d r984a9ba  
    602602}
    603603
    604 static void comp_window_get_event(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
     604static void comp_window_get_event(window_t *win, ipc_call_t *icall)
    605605{
    606606        window_event_t *event = (window_event_t *) prodcons_consume(&win->queue);
    607607
    608         cap_call_handle_t chandle;
     608        ipc_call_t call;
    609609        size_t len;
    610610
    611         if (!async_data_read_receive(&chandle, &len)) {
    612                 async_answer_0(icall_handle, EINVAL);
     611        if (!async_data_read_receive(&call, &len)) {
     612                async_answer_0(icall, EINVAL);
    613613                free(event);
    614614                return;
    615615        }
    616616
    617         errno_t rc = async_data_read_finalize(chandle, event, len);
     617        errno_t rc = async_data_read_finalize(&call, event, len);
    618618        if (rc != EOK) {
    619                 async_answer_0(icall_handle, ENOMEM);
     619                async_answer_0(icall, ENOMEM);
    620620                free(event);
    621621                return;
    622622        }
    623623
    624         async_answer_0(icall_handle, EOK);
     624        async_answer_0(icall, EOK);
    625625        free(event);
    626626}
    627627
    628 static void comp_window_damage(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
     628static void comp_window_damage(window_t *win, ipc_call_t *icall)
    629629{
    630630        double x = IPC_GET_ARG1(*icall);
     
    644644        }
    645645
    646         async_answer_0(icall_handle, EOK);
    647 }
    648 
    649 static void comp_window_grab(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
     646        async_answer_0(icall, EOK);
     647}
     648
     649static void comp_window_grab(window_t *win, ipc_call_t *icall)
    650650{
    651651        sysarg_t pos_id = IPC_GET_ARG1(*icall);
     
    674674        }
    675675
    676         async_answer_0(icall_handle, EOK);
     676        async_answer_0(icall, EOK);
    677677}
    678678
     
    706706}
    707707
    708 static void comp_window_resize(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
    709 {
    710         cap_call_handle_t chandle;
     708static void comp_window_resize(window_t *win, ipc_call_t *icall)
     709{
     710        ipc_call_t call;
    711711        size_t size;
    712712        unsigned int flags;
    713713
    714714        /* Start sharing resized window with client. */
    715         if (!async_share_out_receive(&chandle, &size, &flags)) {
    716                 async_answer_0(icall_handle, EINVAL);
     715        if (!async_share_out_receive(&call, &size, &flags)) {
     716                async_answer_0(icall, EINVAL);
    717717                return;
    718718        }
    719719
    720720        void *new_cell_storage;
    721         errno_t rc = async_share_out_finalize(chandle, &new_cell_storage);
     721        errno_t rc = async_share_out_finalize(&call, &new_cell_storage);
    722722        if ((rc != EOK) || (new_cell_storage == AS_MAP_FAILED)) {
    723                 async_answer_0(icall_handle, ENOMEM);
     723                async_answer_0(icall, ENOMEM);
    724724                return;
    725725        }
     
    730730        if (!new_surface) {
    731731                as_area_destroy(new_cell_storage);
    732                 async_answer_0(icall_handle, ENOMEM);
     732                async_answer_0(icall, ENOMEM);
    733733                return;
    734734        }
     
    817817        comp_damage(x, y, width, height);
    818818
    819         async_answer_0(icall_handle, EOK);
     819        async_answer_0(icall, EOK);
    820820}
    821821
     
    849849}
    850850
    851 static void comp_window_close(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
     851static void comp_window_close(window_t *win, ipc_call_t *icall)
    852852{
    853853        /* Stop managing the window. */
     
    891891
    892892        comp_damage(x, y, width, height);
    893         async_answer_0(icall_handle, EOK);
    894 }
    895 
    896 static void comp_window_close_request(window_t *win, cap_call_handle_t icall_handle, ipc_call_t *icall)
     893        async_answer_0(icall, EOK);
     894}
     895
     896static void comp_window_close_request(window_t *win, ipc_call_t *icall)
    897897{
    898898        window_event_t *event = (window_event_t *) malloc(sizeof(window_event_t));
    899899        if (event == NULL) {
    900                 async_answer_0(icall_handle, ENOMEM);
     900                async_answer_0(icall, ENOMEM);
    901901                return;
    902902        }
     
    906906
    907907        prodcons_produce(&win->queue, &event->link);
    908         async_answer_0(icall_handle, EOK);
    909 }
    910 
    911 static void client_connection(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     908        async_answer_0(icall, EOK);
     909}
     910
     911static void client_connection(ipc_call_t *icall, void *arg)
    912912{
    913913        ipc_call_t call;
    914         cap_call_handle_t chandle;
    915914        service_id_t service_id = (service_id_t) IPC_GET_ARG2(*icall);
    916915
    917916        /* Allocate resources for new window and register it to the location service. */
    918917        if (service_id == winreg_id) {
    919                 async_answer_0(icall_handle, EOK);
    920 
    921                 chandle = async_get_call(&call);
     918                async_answer_0(icall, EOK);
     919
     920                async_get_call(&call);
    922921                if (IPC_GET_IMETHOD(call) == WINDOW_REGISTER) {
    923922                        fibril_mutex_lock(&window_list_mtx);
     
    925924                        window_t *win = window_create();
    926925                        if (!win) {
    927                                 async_answer_2(chandle, ENOMEM, 0, 0);
     926                                async_answer_2(&call, ENOMEM, 0, 0);
    928927                                fibril_mutex_unlock(&window_list_mtx);
    929928                                return;
     
    944943                        if (loc_service_register(name_in, &win->in_dsid) != EOK) {
    945944                                window_destroy(win);
    946                                 async_answer_2(chandle, EINVAL, 0, 0);
     945                                async_answer_2(&call, EINVAL, 0, 0);
    947946                                fibril_mutex_unlock(&window_list_mtx);
    948947                                return;
     
    952951                                loc_service_unregister(win->in_dsid);
    953952                                window_destroy(win);
    954                                 async_answer_2(chandle, EINVAL, 0, 0);
     953                                async_answer_2(&call, EINVAL, 0, 0);
    955954                                fibril_mutex_unlock(&window_list_mtx);
    956955                                return;
     
    966965                        }
    967966
    968                         async_answer_2(chandle, EOK, win->in_dsid, win->out_dsid);
     967                        async_answer_2(&call, EOK, win->in_dsid, win->out_dsid);
    969968                        fibril_mutex_unlock(&window_list_mtx);
    970969
     
    975974                        return;
    976975                } else {
    977                         async_answer_0(chandle, EINVAL);
     976                        async_answer_0(&call, EINVAL);
    978977                        return;
    979978                }
     
    993992        if (win) {
    994993                atomic_inc(&win->ref_cnt);
    995                 async_answer_0(icall_handle, EOK);
     994                async_answer_0(icall, EOK);
    996995        } else {
    997                 async_answer_0(icall_handle, EINVAL);
     996                async_answer_0(icall, EINVAL);
    998997                return;
    999998        }
     
    10021001        if (win->in_dsid == service_id) {
    10031002                while (true) {
    1004                         chandle = async_get_call(&call);
     1003                        async_get_call(&call);
    10051004
    10061005                        if (!IPC_GET_IMETHOD(call)) {
    1007                                 async_answer_0(chandle, EOK);
     1006                                async_answer_0(&call, EOK);
    10081007                                atomic_dec(&win->ref_cnt);
    10091008                                window_destroy(win);
     
    10131012                        switch (IPC_GET_IMETHOD(call)) {
    10141013                        case WINDOW_GET_EVENT:
    1015                                 comp_window_get_event(win, chandle, &call);
     1014                                comp_window_get_event(win, &call);
    10161015                                break;
    10171016                        default:
    1018                                 async_answer_0(chandle, EINVAL);
     1017                                async_answer_0(&call, EINVAL);
    10191018                        }
    10201019                }
    10211020        } else if (win->out_dsid == service_id) {
    10221021                while (true) {
    1023                         chandle = async_get_call(&call);
     1022                        async_get_call(&call);
    10241023
    10251024                        if (!IPC_GET_IMETHOD(call)) {
    1026                                 comp_window_close(win, chandle, &call);
     1025                                comp_window_close(win, &call);
    10271026                                atomic_dec(&win->ref_cnt);
    10281027                                window_destroy(win);
     
    10321031                        switch (IPC_GET_IMETHOD(call)) {
    10331032                        case WINDOW_DAMAGE:
    1034                                 comp_window_damage(win, chandle, &call);
     1033                                comp_window_damage(win, &call);
    10351034                                break;
    10361035                        case WINDOW_GRAB:
    1037                                 comp_window_grab(win, chandle, &call);
     1036                                comp_window_grab(win, &call);
    10381037                                break;
    10391038                        case WINDOW_RESIZE:
    1040                                 comp_window_resize(win, chandle, &call);
     1039                                comp_window_resize(win, &call);
    10411040                                break;
    10421041                        case WINDOW_CLOSE:
     
    10451044                                 * the case when the client is killed abruptly.
    10461045                                 */
    1047                                 async_answer_0(chandle, EOK);
     1046                                async_answer_0(&call, EOK);
    10481047                                break;
    10491048                        case WINDOW_CLOSE_REQUEST:
    1050                                 comp_window_close_request(win, chandle, &call);
     1049                                comp_window_close_request(win, &call);
    10511050                                break;
    10521051                        default:
    1053                                 async_answer_0(chandle, EINVAL);
    1054                         }
    1055                 }
    1056         }
    1057 }
    1058 
    1059 static void comp_mode_change(viewport_t *vp, cap_call_handle_t icall_handle, ipc_call_t *icall)
     1052                                async_answer_0(&call, EINVAL);
     1053                        }
     1054                }
     1055        }
     1056}
     1057
     1058static void comp_mode_change(viewport_t *vp, ipc_call_t *icall)
    10601059{
    10611060        sysarg_t mode_idx = IPC_GET_ARG2(*icall);
     
    10671066        if (rc != EOK) {
    10681067                fibril_mutex_unlock(&viewport_list_mtx);
    1069                 async_answer_0(icall_handle, EINVAL);
     1068                async_answer_0(icall, EINVAL);
    10701069                return;
    10711070        }
     
    10761075        if (!new_surface) {
    10771076                fibril_mutex_unlock(&viewport_list_mtx);
    1078                 async_answer_0(icall_handle, ENOMEM);
     1077                async_answer_0(icall, ENOMEM);
    10791078                return;
    10801079        }
     
    10861085                surface_destroy(new_surface);
    10871086                fibril_mutex_unlock(&viewport_list_mtx);
    1088                 async_answer_0(icall_handle, rc);
     1087                async_answer_0(icall, rc);
    10891088                return;
    10901089        }
     
    10961095
    10971096        fibril_mutex_unlock(&viewport_list_mtx);
    1098         async_answer_0(icall_handle, EOK);
     1097        async_answer_0(icall, EOK);
    10991098
    11001099        comp_restrict_pointers();
     
    11301129        fibril_mutex_unlock(&window_list_mtx);
    11311130
    1132         async_answer_0(icall_handle, EOK);
     1131        async_answer_0(icall, EOK);
    11331132
    11341133        /* All fibrils of the compositor will terminate soon. */
     
    11361135#endif
    11371136
    1138 static void comp_visualizer_disconnect(viewport_t *vp, cap_call_handle_t icall_handle, ipc_call_t *icall)
     1137static void comp_visualizer_disconnect(viewport_t *vp, ipc_call_t *icall)
    11391138{
    11401139        /* Release viewport resources. */
     
    11461145        fibril_mutex_unlock(&viewport_list_mtx);
    11471146
    1148         async_answer_0(icall_handle, EOK);
     1147        async_answer_0(icall, EOK);
    11491148
    11501149        comp_restrict_pointers();
     
    11521151}
    11531152
    1154 static void vsl_notifications(cap_call_handle_t icall_handle, ipc_call_t *icall, void *arg)
     1153static void vsl_notifications(ipc_call_t *icall, void *arg)
    11551154{
    11561155        viewport_t *vp = NULL;
     
    11701169        while (true) {
    11711170                ipc_call_t call;
    1172                 cap_call_handle_t chandle = async_get_call(&call);
     1171                async_get_call(&call);
    11731172
    11741173                if (!IPC_GET_IMETHOD(call)) {
     
    11791178                switch (IPC_GET_IMETHOD(call)) {
    11801179                case VISUALIZER_MODE_CHANGE:
    1181                         comp_mode_change(vp, chandle, &call);
     1180                        comp_mode_change(vp, &call);
    11821181                        break;
    11831182                case VISUALIZER_DISCONNECT:
    1184                         comp_visualizer_disconnect(vp, chandle, &call);
     1183                        comp_visualizer_disconnect(vp, &call);
    11851184                        return;
    11861185                default:
    1187                         async_answer_0(chandle, EINVAL);
     1186                        async_answer_0(&call, EINVAL);
    11881187                }
    11891188        }
Note: See TracChangeset for help on using the changeset viewer.