Changes in kernel/generic/src/ipc/ops/conctmeto.c [334c103:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ops/conctmeto.c
r334c103 ra35b458 42 42 static errno_t request_preprocess(call_t *call, phone_t *phone) 43 43 { 44 /*45 * Create the new phone and capability, but don't publish them yet.46 * That will be done once the phone is connected.47 */48 44 cap_handle_t phone_handle; 49 kobject_t *phone_obj; 50 errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj); 45 errno_t rc = phone_alloc(TASK, &phone_handle); 46 47 /* Remember the phone capability or that an error occured. */ 48 call->priv = (rc == EOK) ? phone_handle : -1; 49 51 50 if (rc != EOK) { 52 call->priv = -1;53 51 return rc; 54 52 } 55 53 54 /* Set arg5 for server */ 55 kobject_t *phone_obj = kobject_get(TASK, phone_handle, 56 KOBJECT_TYPE_PHONE); 56 57 /* Hand over phone_obj's reference to ARG5 */ 57 58 IPC_SET_ARG5(call->data, (sysarg_t) phone_obj->phone); 58 59 /* Remember the handle */60 call->priv = phone_handle;61 59 62 60 return EOK; … … 67 65 cap_handle_t phone_handle = (cap_handle_t) call->priv; 68 66 69 if (phone_handle < 0) 67 if (phone_handle < 0) { 70 68 return EOK; 69 } 71 70 71 phone_dealloc(phone_handle); 72 72 /* Hand over reference from ARG5 to phone->kobject */ 73 73 phone_t *phone = (phone_t *) IPC_GET_ARG5(call->data); 74 /* Drop phone ->kobject's reference */74 /* Drop phone_obj's reference */ 75 75 kobject_put(phone->kobject); 76 cap_free(TASK, phone_handle);77 78 76 return EOK; 79 77 } … … 84 82 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 85 83 86 /* 87 * Get an extra reference and pass it in the answer data. 88 */ 89 kobject_add_ref(phone->kobject); 90 IPC_SET_ARG5(answer->data, (sysarg_t) phone); 91 92 /* If the user accepted the call, connect */ 84 /* If the user accepted call, connect */ 93 85 if (IPC_GET_RETVAL(answer->data) == EOK) { 94 86 /* Hand over reference from phone to the answerbox */ … … 104 96 { 105 97 cap_handle_t phone_handle = (cap_handle_t) answer->priv; 106 phone_t *phone = (phone_t *) IPC_GET_ARG5(answer->data);107 98 108 99 if (IPC_GET_RETVAL(answer->data)) { 109 100 if (phone_handle >= 0) { 110 101 /* 111 * Cleanup the unpublished capability and drop112 * phone->kobject's reference.102 * The phone was indeed allocated and now needs 103 * to be deallocated. 113 104 */ 114 kobject_put(phone->kobject); 115 cap_free(TASK, phone_handle); 105 phone_dealloc(phone_handle); 116 106 } 117 107 } else { 118 /*119 * Publish the capability. Publishing the capability this late120 * is important for ipc_cleanup() where we want to have a121 * capability for each phone that wasn't hung up by the user.122 */123 cap_publish(TASK, phone_handle, phone->kobject);124 125 108 IPC_SET_ARG5(answer->data, phone_handle); 126 109 }
Note:
See TracChangeset
for help on using the changeset viewer.