Changeset 9f22213 in mainline for generic/src/ipc/sysipc.c


Ignore:
Timestamp:
2006-03-19T12:43:12Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7c7aae16
Parents:
b4b45210
Message:

More IPC stuff, added correct closing of connections from both sides.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • generic/src/ipc/sysipc.c

    rb4b45210 r9f22213  
    7676
    7777/** Return true if the caller (ipc_answer) should save
    78  * the old call contents and call answer_preprocess
    79  */
    80 static inline int answer_will_preprocess(call_t *call)
     78 * the old call contents for answer_preprocess
     79 */
     80static inline int answer_need_old(call_t *call)
    8181{
    8282        if (IPC_GET_METHOD(call->data) == IPC_M_CONNECT_TO_ME)
     
    9191{
    9292        int phoneid;
     93
     94        if (IPC_GET_RETVAL(answer->data) == EHANGUP) {
     95                /* Atomic operation */
     96                answer->data.phone->callee = NULL;
     97        }
     98
     99        if (!olddata)
     100                return;
    93101
    94102        if (IPC_GET_METHOD(*olddata) == IPC_M_CONNECT_TO_ME) {
     
    98106                        phone_dealloc(phoneid);
    99107                } else {
    100                         /* The connection was accepted */
     108                                /* The connection was accepted */
    101109                        phone_connect(phoneid,&answer->sender->answerbox);
    102110                }
     
    118126static int process_answer(answerbox_t *box,call_t *call)
    119127{
     128        if (IPC_GET_RETVAL(call->data) == EHANGUP && \
     129            call->flags & IPC_CALL_FORWARDED)
     130                IPC_SET_RETVAL(call->data, EFORWARD);
    120131        return 0;
    121132}
     
    276287                return ENOENT;
    277288
     289        call->flags |= IPC_CALL_FORWARDED;
     290
    278291        GET_CHECK_PHONE(phone, phoneid, {
    279292                IPC_SET_RETVAL(call->data, EFORWARD);
     
    299312        }
    300313
    301         ipc_forward(call, phone, &TASK->answerbox);
    302 
    303         return 0;
     314        return ipc_forward(call, phone, &TASK->answerbox);
    304315}
    305316
     
    310321        call_t *call;
    311322        ipc_data_t saved_data;
    312         int preprocess = 0;
     323        int saveddata = 0;
    313324
    314325        call = get_call(callid);
     
    316327                return ENOENT;
    317328
    318         if (answer_will_preprocess(call)) {
     329        if (answer_need_old(call)) {
    319330                memcpy(&saved_data, &call->data, sizeof(call->data));
    320                 preprocess = 1;
     331                saveddata = 1;
    321332        }
    322333
     
    324335        IPC_SET_ARG1(call->data, arg1);
    325336        IPC_SET_ARG2(call->data, arg2);
    326 
    327         if (preprocess)
    328                 answer_preprocess(call, &saved_data);
     337        answer_preprocess(call, saveddata ? &saved_data : NULL);
    329338
    330339        ipc_answer(&TASK->answerbox, call);
     
    337346        call_t *call;
    338347        ipc_data_t saved_data;
    339         int preprocess = 0;
     348        int saveddata = 0;
    340349
    341350        call = get_call(callid);
     
    343352                return ENOENT;
    344353
    345         if (answer_will_preprocess(call)) {
     354        if (answer_need_old(call)) {
    346355                memcpy(&saved_data, &call->data, sizeof(call->data));
    347                 preprocess = 1;
     356                saveddata = 1;
    348357        }
    349358        copy_from_uspace(&call->data.args, &data->args,
    350359                         sizeof(call->data.args));
    351360
    352         if (preprocess)
    353                 answer_preprocess(call, &saved_data);
     361        answer_preprocess(call, saveddata ? &saved_data : NULL);
    354362       
    355363        ipc_answer(&TASK->answerbox, call);
     
    449457restart:       
    450458        call = ipc_wait_for_call(&TASK->answerbox, flags);
     459        if (!call)
     460                return 0;
    451461
    452462        if (call->flags & IPC_CALL_ANSWERED) {
Note: See TracChangeset for help on using the changeset viewer.