Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ops/conctmeto.c

    r022d72ff r48bcf49  
    11/*
    22 * Copyright (c) 2006 Ondrej Palkovsky
    3  * Copyright (c) 2012 Jakub Jermar 
     3 * Copyright (c) 2012 Jakub Jermar
    44 * All rights reserved.
    55 *
     
    4242static int request_preprocess(call_t *call, phone_t *phone)
    4343{
    44         int newphid = phone_alloc(TASK);
     44        cap_handle_t phone_handle = phone_alloc(TASK);
    4545
    46         /* Remember the phoneid or the error. */
    47         call->priv = newphid;
    48         if (newphid < 0)
    49                 return ELIMIT;
    50                
     46        /* Remember the phone capability or the error. */
     47        call->priv = phone_handle;
     48        if (phone_handle < 0)
     49                return phone_handle;
     50
    5151        /* Set arg5 for server */
    52         IPC_SET_ARG5(call->data, (sysarg_t) &TASK->phones[newphid]);
     52        kobject_t *phone_obj = kobject_get(TASK, phone_handle,
     53            KOBJECT_TYPE_PHONE);
     54        /* Hand over phone_obj's reference to ARG5 */
     55        IPC_SET_ARG5(call->data, (sysarg_t) phone_obj->phone);
    5356
    5457        return EOK;
     
    5760static int request_forget(call_t *call)
    5861{
    59         phone_dealloc(call->priv);
     62        cap_handle_t phone_handle = (cap_handle_t) call->priv;
     63        phone_dealloc(phone_handle);
     64        /* Hand over reference from ARG5 to phone->kobject */
     65        phone_t *phone = (phone_t *) IPC_GET_ARG5(call->data);
     66        /* Drop phone_obj's reference */
     67        kobject_put(phone->kobject);
    6068        return EOK;
    6169}
     
    6371static int answer_preprocess(call_t *answer, ipc_data_t *olddata)
    6472{
     73        /* Hand over reference from ARG5 to phone */
    6574        phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata);
    6675
    6776        /* If the user accepted call, connect */
    68         if (IPC_GET_RETVAL(answer->data) == EOK)
     77        if (IPC_GET_RETVAL(answer->data) == EOK) {
     78                /* Hand over reference from phone to the answerbox */
    6979                (void) ipc_phone_connect(phone, &TASK->answerbox);
     80        } else {
     81                kobject_put(phone->kobject);
     82        }
    7083
    7184        return EOK;
     
    7487static int answer_process(call_t *answer)
    7588{
    76         int newphid = (int) answer->priv;
     89        cap_handle_t phone_handle = (cap_handle_t) answer->priv;
    7790
    7891        if (IPC_GET_RETVAL(answer->data)) {
    79                 if (newphid >= 0) {
     92                if (phone_handle >= 0) {
    8093                        /*
    8194                         * The phone was indeed allocated and now needs
    8295                         * to be deallocated.
    8396                         */
    84                         phone_dealloc(newphid);
     97                        phone_dealloc(phone_handle);
    8598                }
    8699        } else {
    87                 IPC_SET_ARG5(answer->data, newphid);
     100                IPC_SET_ARG5(answer->data, phone_handle);
    88101        }
    89102       
Note: See TracChangeset for help on using the changeset viewer.