Changeset 4d6629f in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2017-09-03T14:15:32Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9306cd7
- Parents:
- 8a45bf09
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r8a45bf09 r4d6629f 1357 1357 async_new_connection(call->in_task_id, in_phone_hash, callid, 1358 1358 call, handler, data); 1359 return;1360 }1361 1362 /* Cloned connection */1363 if (IPC_GET_IMETHOD(*call) == IPC_M_CLONE_ESTABLISH) {1364 // TODO: Currently ignores ports altogether1365 1366 /* Open new connection with fibril, etc. */1367 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call),1368 callid, call, fallback_port_handler, fallback_port_data);1369 1359 return; 1370 1360 } … … 2084 2074 2085 2075 return EOK; 2086 }2087 2088 /** Wrapper for making IPC_M_CLONE_ESTABLISH calls using the async framework.2089 *2090 * Ask for a cloned connection to some service.2091 *2092 * @param mgmt Exchange management style.2093 * @param exch Exchange for sending the message.2094 *2095 * @return New session on success or NULL on error.2096 *2097 */2098 async_sess_t *async_clone_establish(exch_mgmt_t mgmt, async_exch_t *exch)2099 {2100 if (exch == NULL) {2101 errno = ENOENT;2102 return NULL;2103 }2104 2105 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));2106 if (sess == NULL) {2107 errno = ENOMEM;2108 return NULL;2109 }2110 2111 ipc_call_t result;2112 2113 amsg_t *msg = amsg_create();2114 if (!msg) {2115 free(sess);2116 errno = ENOMEM;2117 return NULL;2118 }2119 2120 msg->dataptr = &result;2121 msg->wdata.active = true;2122 2123 ipc_call_async_0(exch->phone, IPC_M_CLONE_ESTABLISH, msg,2124 reply_received);2125 2126 sysarg_t rc;2127 async_wait_for((aid_t) msg, &rc);2128 2129 if (rc != EOK) {2130 errno = rc;2131 free(sess);2132 return NULL;2133 }2134 2135 int phone = (int) IPC_GET_ARG5(result);2136 2137 if (phone < 0) {2138 errno = phone;2139 free(sess);2140 return NULL;2141 }2142 2143 sess->iface = 0;2144 sess->mgmt = mgmt;2145 sess->phone = phone;2146 sess->arg1 = 0;2147 sess->arg2 = 0;2148 sess->arg3 = 0;2149 2150 fibril_mutex_initialize(&sess->remote_state_mtx);2151 sess->remote_state_data = NULL;2152 2153 list_initialize(&sess->exch_list);2154 fibril_mutex_initialize(&sess->mutex);2155 atomic_set(&sess->refcnt, 0);2156 2157 return sess;2158 2076 } 2159 2077 … … 3126 3044 } 3127 3045 3128 /** Wrapper for sending an exchange over different exchange for cloning3129 *3130 * @param exch Exchange to be used for sending.3131 * @param clone_exch Exchange to be cloned.3132 *3133 */3134 int async_exchange_clone(async_exch_t *exch, async_exch_t *clone_exch)3135 {3136 return async_req_1_0(exch, IPC_M_CONNECTION_CLONE, clone_exch->phone);3137 }3138 3139 /** Wrapper for receiving the IPC_M_CONNECTION_CLONE calls.3140 *3141 * If the current call is IPC_M_CONNECTION_CLONE then a new3142 * async session is created for the accepted phone.3143 *3144 * @param mgmt Exchange management style.3145 *3146 * @return New async session or NULL on failure.3147 *3148 */3149 async_sess_t *async_clone_receive(exch_mgmt_t mgmt)3150 {3151 /* Accept the phone */3152 ipc_call_t call;3153 ipc_callid_t callid = async_get_call(&call);3154 int phone = (int) IPC_GET_ARG1(call);3155 3156 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) ||3157 (phone < 0)) {3158 async_answer_0(callid, EINVAL);3159 return NULL;3160 }3161 3162 async_sess_t *sess = (async_sess_t *) malloc(sizeof(async_sess_t));3163 if (sess == NULL) {3164 async_answer_0(callid, ENOMEM);3165 return NULL;3166 }3167 3168 sess->iface = 0;3169 sess->mgmt = mgmt;3170 sess->phone = phone;3171 sess->arg1 = 0;3172 sess->arg2 = 0;3173 sess->arg3 = 0;3174 3175 fibril_mutex_initialize(&sess->remote_state_mtx);3176 sess->remote_state_data = NULL;3177 3178 list_initialize(&sess->exch_list);3179 fibril_mutex_initialize(&sess->mutex);3180 atomic_set(&sess->refcnt, 0);3181 3182 /* Acknowledge the cloned phone */3183 async_answer_0(callid, EOK);3184 3185 return sess;3186 }3187 3188 3046 /** Wrapper for receiving the IPC_M_CONNECT_TO_ME calls. 3189 3047 *
Note:
See TracChangeset
for help on using the changeset viewer.