Changeset 67f11a0 in mainline for kernel/generic/src/ipc/ops
- Timestamp:
- 2018-03-15T17:40:20Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 530f2de, e9e4068
- Parents:
- 30f1a25 (diff), a36f442 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - git-author:
- Jakub Jermar <jakub@…> (2018-03-15 17:25:56)
- git-committer:
- Jakub Jermar <jakub@…> (2018-03-15 17:40:20)
- Location:
- kernel/generic/src/ipc/ops
- Files:
-
- 2 edited
-
conctmeto.c (modified) (4 diffs)
-
concttome.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/ops/conctmeto.c
r30f1a25 r67f11a0 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 */ 44 48 cap_handle_t phone_handle; 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 49 kobject_t *phone_obj; 50 errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj); 50 51 if (rc != EOK) { 52 call->priv = -1; 51 53 return rc; 52 54 } 53 55 54 /* Set arg5 for server */55 kobject_t *phone_obj = kobject_get(TASK, phone_handle,56 KOBJECT_TYPE_PHONE);57 56 /* Hand over phone_obj's reference to ARG5 */ 58 57 IPC_SET_ARG5(call->data, (sysarg_t) phone_obj->phone); 58 59 /* Remember the handle */ 60 call->priv = phone_handle; 59 61 60 62 return EOK; … … 65 67 cap_handle_t phone_handle = (cap_handle_t) call->priv; 66 68 67 if (phone_handle < 0) {69 if (phone_handle < 0) 68 70 return EOK; 69 }70 71 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 _obj's reference */74 /* Drop phone->kobject's reference */ 75 75 kobject_put(phone->kobject); 76 cap_free(TASK, phone_handle); 77 76 78 return EOK; 77 79 } … … 82 84 phone_t *phone = (phone_t *) IPC_GET_ARG5(*olddata); 83 85 84 /* If the user accepted call, connect */ 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 */ 85 93 if (IPC_GET_RETVAL(answer->data) == EOK) { 86 94 /* Hand over reference from phone to the answerbox */ … … 96 104 { 97 105 cap_handle_t phone_handle = (cap_handle_t) answer->priv; 106 phone_t *phone = (phone_t *) IPC_GET_ARG5(answer->data); 98 107 99 108 if (IPC_GET_RETVAL(answer->data)) { 100 109 if (phone_handle >= 0) { 101 110 /* 102 * The phone was indeed allocated and now needs103 * to be deallocated.111 * Cleanup the unpublished capability and drop 112 * phone->kobject's reference. 104 113 */ 105 phone_dealloc(phone_handle); 114 kobject_put(phone->kobject); 115 cap_free(TASK, phone_handle); 106 116 } 107 117 } else { 118 /* 119 * Publish the capability. Publishing the capability this late 120 * is important for ipc_cleanup() where we want to have a 121 * capability for each phone that wasn't hung up by the user. 122 */ 123 cap_publish(TASK, phone_handle, phone->kobject); 124 108 125 IPC_SET_ARG5(answer->data, phone_handle); 109 126 } -
kernel/generic/src/ipc/ops/concttome.c
r30f1a25 r67f11a0 43 43 { 44 44 cap_handle_t phone_handle; 45 errno_t rc = phone_alloc(TASK, &phone_handle); 45 kobject_t *phone_obj; 46 errno_t rc = phone_alloc(TASK, false, &phone_handle, &phone_obj); 47 call->priv = (sysarg_t) phone_obj; 46 48 IPC_SET_ARG5(call->data, (rc == EOK) ? phone_handle : -1); 47 49 return 0; … … 51 53 { 52 54 cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata); 55 kobject_t *phone_obj = (kobject_t *) answer->priv; 53 56 54 if (phone_handle >= 0) 55 phone_dealloc(phone_handle); 57 if (phone_handle >= 0) { 58 kobject_put(phone_obj); 59 cap_free(TASK, phone_handle); 60 } 56 61 57 62 return EOK; … … 61 66 { 62 67 cap_handle_t phone_handle = (cap_handle_t) IPC_GET_ARG5(*olddata); 68 kobject_t *phone_obj = (kobject_t *) answer->priv; 63 69 64 70 if (IPC_GET_RETVAL(answer->data) != EOK) { … … 66 72 answer_cleanup(answer, olddata); 67 73 } else if (phone_handle >= 0) { 68 /* The connection was accepted */ 69 if (phone_connect(phone_handle, &answer->sender->answerbox)) { 74 /* 75 * The connection was accepted 76 */ 77 78 /* 79 * We need to create another reference as the one we have now 80 * will be consumed by ipc_phone_connect(). 81 */ 82 kobject_add_ref(phone_obj); 83 84 if (ipc_phone_connect(phone_obj->phone, 85 &answer->sender->answerbox)) { 86 /* Pass the reference to the capability */ 87 cap_publish(TASK, phone_handle, phone_obj); 70 88 /* Set 'phone hash' as ARG5 of response */ 71 kobject_t *phone_obj = kobject_get(TASK, phone_handle,72 KOBJECT_TYPE_PHONE);73 89 IPC_SET_ARG5(answer->data, 74 90 (sysarg_t) phone_obj->phone); 75 kobject_put(phone_obj);76 91 } else { 77 92 /* The answerbox is shutting down. */
Note:
See TracChangeset
for help on using the changeset viewer.
