Changeset ba81cab in mainline for generic/src/ipc/sysipc.c


Ignore:
Timestamp:
2006-03-18T01:06:13Z (19 years ago)
Author:
Ondrej Palkovsky <ondrap@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fbcfd458
Parents:
81c4c6da
Message:

Better IPC implementation with regard to locking and final cleanup.

File:
1 edited

Legend:

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

    r81c4c6da rba81cab  
    4747 *
    4848 */
     49
     50#define GET_CHECK_PHONE(phone,phoneid,err) { \
     51      if (phoneid > IPC_MAX_PHONES) { err; } \
     52      phone = &TASK->phones[phoneid]; \
     53}
     54
    4955
    5056/** Return true if the method is a system method */
     
    151157                return EPERM;
    152158
    153         phone = get_phone_and_lock(phoneid);
    154         if (!phone)
    155                 return ENOENT;
    156 
    157         ipc_call_init(&call);
     159        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
     160
     161        ipc_call_static_init(&call);
    158162        IPC_SET_METHOD(call.data, method);
    159163        IPC_SET_ARG1(call.data, arg1);
     
    173177        phone_t *phone;
    174178
    175         ipc_call_init(&call);
     179        ipc_call_static_init(&call);
    176180        copy_from_uspace(&call.data, question, sizeof(call.data));
    177181
     
    179183                return EPERM;
    180184       
    181         phone = get_phone_and_lock(phoneid);
    182         if (!phone)
    183                 return ENOENT;
     185        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
    184186
    185187        ipc_call_sync(phone, &call);
     
    220222                return IPC_CALLRET_TEMPORARY;
    221223
    222         phone = get_phone_and_lock(phoneid);
    223         if (!phone)
    224                 return IPC_CALLRET_FATAL;
     224        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
    225225
    226226        call = ipc_call_alloc();
     
    246246                return IPC_CALLRET_TEMPORARY;
    247247
    248         phone = get_phone_and_lock(phoneid);
    249         if (!phone)
    250                 return IPC_CALLRET_FATAL;
     248        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
    251249
    252250        call = ipc_call_alloc();
     
    280278                return ENOENT;
    281279
    282         phone = get_phone_and_lock(phoneid);
    283         if (!phone) {
     280        GET_CHECK_PHONE(phone, phoneid, {
    284281                IPC_SET_RETVAL(call->data, EFORWARD);
    285282                ipc_answer(&TASK->answerbox, call);
    286283                return ENOENT;
    287         }
     284        });             
    288285
    289286        if (!is_forwardable(IPC_GET_METHOD(call->data))) {
     
    304301        }
    305302
    306         ipc_forward(call, phone->callee, &TASK->answerbox);
     303        ipc_forward(call, phone, &TASK->answerbox);
    307304
    308305        return 0;
     
    372369        phone_t *phone;
    373370
    374         ipc_call_init(&call);
     371        ipc_call_static_init(&call);
    375372        IPC_SET_METHOD(call.data, IPC_M_CONNECTTOME);
    376373        IPC_SET_ARG1(call.data, arg1);
    377374        IPC_SET_ARG2(call.data, arg2);
    378375       
    379         phone = get_phone_and_lock(phoneid);
    380         if (!phone)
    381                 return ENOENT;
     376        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
    382377
    383378        ipc_call_sync(phone, &call);
     
    402397        int newphid;
    403398
    404         phone = get_phone_and_lock(phoneid);
    405         if (!phone)
    406                 return ENOENT;
     399        GET_CHECK_PHONE(phone, phoneid, return ENOENT);
    407400
    408401        newphid = phone_alloc();
     
    410403                return ELIMIT;
    411404
    412         ipc_call_init(&call);
     405        ipc_call_static_init(&call);
    413406        IPC_SET_METHOD(call.data, IPC_M_CONNECTMETO);
    414407        IPC_SET_ARG1(call.data, arg1);
Note: See TracChangeset for help on using the changeset viewer.