Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d57c7c2 in mainline


Ignore:
Timestamp:
2018-11-04T14:34:08Z (3 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
9c26ef0
Parents:
9c1841b
Message:

Make sure not to answer async calls twice

This commit explicitly invalidates the remembered capability handle
so that the async framework can detect when a call is answered twice.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async/server.c

    r9c1841b rd57c7c2  
    10251025errno_t async_accept_0(ipc_call_t *call)
    10261026{
    1027         return ipc_answer_5(call->cap_handle, EOK, 0, 0, 0, 0,
    1028             async_get_label());
     1027        cap_call_handle_t chandle = call->cap_handle;
     1028        assert(chandle != CAP_NIL);
     1029        call->cap_handle = CAP_NIL;
     1030        return ipc_answer_5(chandle, EOK, 0, 0, 0, 0, async_get_label());
    10291031}
    10301032
    10311033errno_t async_answer_0(ipc_call_t *call, errno_t retval)
    10321034{
    1033         return ipc_answer_0(call->cap_handle, retval);
     1035        cap_call_handle_t chandle = call->cap_handle;
     1036        assert(chandle != CAP_NIL);
     1037        call->cap_handle = CAP_NIL;
     1038        return ipc_answer_0(chandle, retval);
    10341039}
    10351040
    10361041errno_t async_answer_1(ipc_call_t *call, errno_t retval, sysarg_t arg1)
    10371042{
    1038         return ipc_answer_1(call->cap_handle, retval, arg1);
     1043        cap_call_handle_t chandle = call->cap_handle;
     1044        assert(chandle != CAP_NIL);
     1045        call->cap_handle = CAP_NIL;
     1046        return ipc_answer_1(chandle, retval, arg1);
    10391047}
    10401048
     
    10421050    sysarg_t arg2)
    10431051{
    1044         return ipc_answer_2(call->cap_handle, retval, arg1, arg2);
     1052        cap_call_handle_t chandle = call->cap_handle;
     1053        assert(chandle != CAP_NIL);
     1054        call->cap_handle = CAP_NIL;
     1055        return ipc_answer_2(chandle, retval, arg1, arg2);
    10451056}
    10461057
     
    10481059    sysarg_t arg2, sysarg_t arg3)
    10491060{
    1050         return ipc_answer_3(call->cap_handle, retval, arg1, arg2, arg3);
     1061        cap_call_handle_t chandle = call->cap_handle;
     1062        assert(chandle != CAP_NIL);
     1063        call->cap_handle = CAP_NIL;
     1064        return ipc_answer_3(chandle, retval, arg1, arg2, arg3);
    10511065}
    10521066
     
    10541068    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4)
    10551069{
    1056         return ipc_answer_4(call->cap_handle, retval, arg1, arg2, arg3, arg4);
     1070        cap_call_handle_t chandle = call->cap_handle;
     1071        assert(chandle != CAP_NIL);
     1072        call->cap_handle = CAP_NIL;
     1073        return ipc_answer_4(chandle, retval, arg1, arg2, arg3, arg4);
    10571074}
    10581075
     
    10601077    sysarg_t arg2, sysarg_t arg3, sysarg_t arg4, sysarg_t arg5)
    10611078{
    1062         return ipc_answer_5(call->cap_handle, retval, arg1, arg2, arg3, arg4,
    1063             arg5);
     1079        cap_call_handle_t chandle = call->cap_handle;
     1080        assert(chandle != CAP_NIL);
     1081        call->cap_handle = CAP_NIL;
     1082        return ipc_answer_5(chandle, retval, arg1, arg2, arg3, arg4, arg5);
    10641083}
    10651084
     
    10691088        assert(call);
    10701089
     1090        cap_call_handle_t chandle = call->cap_handle;
     1091        assert(chandle != CAP_NIL);
     1092        call->cap_handle = CAP_NIL;
     1093
    10711094        if (exch == NULL)
    10721095                return ENOENT;
    10731096
    1074         return ipc_forward_fast(call->cap_handle, exch->phone, imethod, arg1,
    1075             arg2, mode);
     1097        return ipc_forward_fast(chandle, exch->phone, imethod, arg1, arg2,
     1098            mode);
    10761099}
    10771100
     
    10821105        assert(call);
    10831106
     1107        cap_call_handle_t chandle = call->cap_handle;
     1108        assert(chandle != CAP_NIL);
     1109        call->cap_handle = CAP_NIL;
     1110
    10841111        if (exch == NULL)
    10851112                return ENOENT;
    10861113
    1087         return ipc_forward_slow(call->cap_handle, exch->phone, imethod, arg1,
    1088             arg2, arg3, arg4, arg5, mode);
     1114        return ipc_forward_slow(chandle, exch->phone, imethod, arg1, arg2, arg3,
     1115            arg4, arg5, mode);
    10891116}
    10901117
     
    11591186        assert(call);
    11601187
    1161         return ipc_answer_2(call->cap_handle, EOK, (sysarg_t) src, (sysarg_t) flags);
     1188        cap_call_handle_t chandle = call->cap_handle;
     1189        assert(chandle != CAP_NIL);
     1190        call->cap_handle = CAP_NIL;
     1191
     1192        return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) flags);
    11621193}
    11631194
     
    12111242        assert(call);
    12121243
    1213         return ipc_answer_2(call->cap_handle, EOK, (sysarg_t) __progsymbols.end,
     1244        cap_call_handle_t chandle = call->cap_handle;
     1245        assert(chandle != CAP_NIL);
     1246        call->cap_handle = CAP_NIL;
     1247
     1248        return ipc_answer_2(chandle, EOK, (sysarg_t) __progsymbols.end,
    12141249            (sysarg_t) dst);
    12151250}
     
    12621297        assert(call);
    12631298
    1264         return ipc_answer_2(call->cap_handle, EOK, (sysarg_t) src,
    1265             (sysarg_t) size);
     1299        cap_call_handle_t chandle = call->cap_handle;
     1300        assert(chandle != CAP_NIL);
     1301        call->cap_handle = CAP_NIL;
     1302
     1303        return ipc_answer_2(chandle, EOK, (sysarg_t) src, (sysarg_t) size);
    12661304}
    12671305
Note: See TracChangeset for help on using the changeset viewer.