Changeset 50dd854 in mainline
- Timestamp:
- 2018-03-13T18:01:48Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 334c103
- Parents:
- 1b4196d
- git-author:
- Jakub Jermar <jakub@…> (2018-03-10 17:56:32)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-13 18:01:48)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ops/conctmeto.c
r1b4196d r50dd854 44 44 cap_handle_t phone_handle; 45 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 50 46 if (rc != EOK) { 47 call->priv = -1; 51 48 return rc; 52 49 } 53 50 54 /* Set ARG5 for server */ 55 kobject_t *phone_obj = kobject_get(TASK, phone_handle, 51 /* 52 * The capability is now published, but the phone is not connected yet. 53 * The user cannot use it to send anything over it, in fact the 54 * userspace can only unpublish and free the capability at this point. 55 * 56 * We now proceed to test the capability is still there. We don't care 57 * if the user destroyed the old one and recreated a new published one 58 * of the same type under the same handle. 59 * 60 * If the capability is in place we temporarily unpublish it to make 61 * sure the user cannot fiddle with it while we are connecting. 62 */ 63 64 kobject_t *phone_obj = cap_unpublish(TASK, phone_handle, 56 65 KOBJECT_TYPE_PHONE); 57 66 if (!phone_obj) { … … 63 72 return ENOENT; 64 73 } 74 65 75 /* Hand over phone_obj's reference to ARG5 */ 66 76 IPC_SET_ARG5(call->data, (sysarg_t) phone_obj->phone); 77 78 /* Remember the handle */ 79 call->priv = phone_handle; 67 80 68 81 return EOK; … … 73 86 cap_handle_t phone_handle = (cap_handle_t) call->priv; 74 87 75 if (phone_handle < 0) {88 if (phone_handle < 0) 76 89 return EOK; 77 }78 90 79 phone_dealloc(phone_handle);80 91 /* Hand over reference from ARG5 to phone->kobject */ 81 92 phone_t *phone = (phone_t *) IPC_GET_ARG5(call->data); 82 /* Drop phone _obj's reference */93 /* Drop phone->kobject's reference */ 83 94 kobject_put(phone->kobject); 95 cap_free(TASK, phone_handle); 96 84 97 return EOK; 85 98 } … … 90 103 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 91 104 92 /* If the user accepted call, connect */ 105 /* 106 * Get an extra reference and pass it in the answer data. 107 */ 108 kobject_add_ref(phone->kobject); 109 IPC_SET_ARG5(answer->data, (sysarg_t) phone); 110 111 /* If the user accepted the call, connect */ 93 112 if (IPC_GET_RETVAL(answer->data) == EOK) { 94 113 /* Hand over reference from phone to the answerbox */ … … 104 123 { 105 124 cap_handle_t phone_handle = (cap_handle_t) answer->priv; 125 phone_t *phone = (phone_t *) IPC_GET_ARG5(answer->data); 106 126 107 127 if (IPC_GET_RETVAL(answer->data)) { 108 128 if (phone_handle >= 0) { 109 129 /* 110 * The phone was indeed allocated and now needs111 * to be deallocated.130 * Cleanup the unpublished capability and drop 131 * phone->kobject's reference. 112 132 */ 113 phone_dealloc(phone_handle); 133 kobject_put(phone->kobject); 134 cap_free(TASK, phone_handle); 114 135 } 115 136 } else { 137 /* 138 * Publish the capability. Publishing the capability this late 139 * is important for ipc_cleanup() where we want to have a 140 * capability for each phone that wasn't hung up by the user. 141 */ 142 cap_publish(TASK, phone_handle, phone->kobject); 143 116 144 IPC_SET_ARG5(answer->data, phone_handle); 117 145 }
Note:
See TracChangeset
for help on using the changeset viewer.