Changeset 16d748ee in mainline
- Timestamp:
- 2020-01-05T03:04:38Z (5 years ago)
- Children:
- 66b1075
- Parents:
- 2f04bdd
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2019-11-30 20:47:26)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-01-05 03:04:38)
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async/client.c
r2f04bdd r16d748ee 857 857 if (sess == NULL) { 858 858 ipc_hangup(phone); 859 } else {859 } else { 860 860 sess->iface = iface; 861 861 } … … 915 915 if (sess == NULL) { 916 916 ipc_hangup(phone); 917 } else {917 } else { 918 918 sess->iface = iface; 919 919 } -
uspace/lib/c/generic/async/server.c
r2f04bdd r16d748ee 216 216 } 217 217 218 static async_port_handler_t implicit_connection = NULL;219 220 /** Setter for implicit_connection function pointer.221 *222 * @param conn Function that will implement a new connection fibril for223 * unrouted calls.224 *225 */226 void async_set_implicit_connection(async_port_handler_t conn)227 {228 assert(implicit_connection == NULL);229 implicit_connection = conn;230 }231 232 218 static fibril_rmutex_t client_mutex; 233 219 static hash_table_t client_hash_table; … … 407 393 * either a callback connection that was opened by 408 394 * accepting the IPC_M_CONNECT_TO_ME call. 409 * Alternatively, it is zero when we are opening410 * implicit connection.411 395 * @param handler Connection handler. 412 396 * @param data Client argument to pass to the connection handler. … … 979 963 /* Route the call according to its request label */ 980 964 errno_t rc = route_call(call); 981 if (rc == EOK) {965 if (rc == EOK) 982 966 return; 983 } else if (implicit_connection != NULL) {984 connection_t *conn = calloc(1, sizeof(connection_t));985 if (!conn) {986 ipc_answer_0(call->cap_handle, ENOMEM);987 return;988 }989 990 async_new_connection(conn, call->task_id, call, implicit_connection, NULL);991 return;992 }993 967 994 968 // TODO: Log the error. 995 996 969 if (call->cap_handle != CAP_NIL) 997 970 /* Unknown call from unknown phone - hang it up */ -
uspace/lib/c/generic/taskman.c
r2f04bdd r16d748ee 69 69 async_exchange_end(exch); 70 70 } 71 #include <stdio.h> 71 72 72 /** Wrap PHONE_INITIAL with session and introduce to taskman 73 73 */ … … 85 85 /* Introduce ourselves and ignore answer */ 86 86 async_exch_t *exch = async_exchange_begin(sess); 87 aid_t req = async_send_0(exch, TASKMAN_NEW_TASK, NULL); 87 sess = async_connect_me_to(exch, INTERFACE_ANY, 88 TASKMAN_NEW_TASK, 0); 88 89 async_exchange_end(exch); 89 90 if (req) {91 async_forget(req);92 }93 90 } 94 91 -
uspace/lib/c/include/ipc/taskman.h
r2f04bdd r16d748ee 43 43 TASKMAN_EVENT_CALLBACK, 44 44 TASKMAN_NEW_TASK, 45 TASKMAN_I_AM_NS 45 TASKMAN_I_AM_NS, 46 47 TASKMAN_CONNECT_TO_NS, 48 TASKMAN_CONNECT_TO_LOADER, 49 TASKMAN_LOADER_CALLBACK 46 50 } taskman_request_t; 47 51 … … 50 54 } taskman_event_t; 51 55 52 typedef enum {53 TASKMAN_CONNECT_TO_NS = 0,54 TASKMAN_CONNECT_TO_LOADER,55 TASKMAN_LOADER_CALLBACK56 } taskman_connect_t;57 58 56 #endif 59 57 -
uspace/srv/taskman/main.c
r2f04bdd r16d748ee 36 36 * @{ 37 37 */ 38 38 #include <abi/ipc/methods.h> 39 39 #include <adt/prodcons.h> 40 40 #include <assert.h> … … 124 124 async_exchange_end(exch); 125 125 126 if (rc != EOK) { 127 async_answer_0(icall, rc); 128 return; 129 } 126 if (rc != EOK) 127 async_answer_0(icall, rc); 130 128 } 131 129 … … 133 131 { 134 132 errno_t rc = task_intro(icall->task_id); 135 async_answer_0(icall, rc); 133 if (rc == EOK) { 134 async_accept_0(icall); 135 } else { 136 async_answer_0(icall, rc); 137 } 136 138 } 137 139 … … 158 160 finish: 159 161 fibril_mutex_unlock(&session_ns_mtx); 160 async_answer_0(icall, rc); 162 163 if (rc == EOK) { 164 async_accept_0(icall); 165 } else { 166 async_answer_0(icall, rc); 167 } 161 168 } 162 169 … … 240 247 } 241 248 242 static bool handle_call(ipc_call_t *icall) 243 { 244 switch (ipc_get_imethod(icall)) { 245 case TASKMAN_NEW_TASK: 246 taskman_new_task(icall); 247 break; 248 case TASKMAN_I_AM_NS: 249 taskman_i_am_ns(icall); 250 break; 251 case TASKMAN_WAIT: 252 taskman_ctl_wait(icall); 253 break; 254 case TASKMAN_RETVAL: 255 taskman_ctl_retval(icall); 256 break; 257 case TASKMAN_EVENT_CALLBACK: 258 taskman_ctl_ev_callback(icall); 259 break; 260 default: 261 return false; 262 } 263 return true; 264 } 265 266 static bool handle_implicit_call(ipc_call_t *icall) 267 { 268 if (ipc_get_imethod(icall) < IPC_FIRST_USER_METHOD) { 269 switch (ipc_get_arg1(icall)) { 249 static void taskman_connection(ipc_call_t *icall, void *arg) 250 { 251 /* handle new incoming calls */ 252 if (ipc_get_imethod(icall) == IPC_M_CONNECT_ME_TO) { 253 switch (ipc_get_arg2(icall)) { 254 case TASKMAN_NEW_TASK: 255 taskman_new_task(icall); 256 break; 270 257 case TASKMAN_CONNECT_TO_NS: 271 258 connect_to_ns(icall); 272 break;259 return; 273 260 case TASKMAN_CONNECT_TO_LOADER: 274 261 connect_to_loader(icall); 275 break; 262 return; 263 default: 264 async_answer_0(icall, ENOTSUP); 265 return; 266 } 267 } else if (ipc_get_imethod(icall) == IPC_M_CONNECT_TO_ME) { 268 switch (ipc_get_arg2(icall)) { 276 269 case TASKMAN_LOADER_CALLBACK: 277 270 loader_callback(icall); 278 break;271 return; 279 272 default: 280 return false;281 273 async_answer_0(icall, ENOTSUP); 274 return; 282 275 } 283 } else { 284 return handle_call(icall); 285 } 286 287 return true; 288 } 289 290 static void implicit_connection(ipc_call_t *icall, void *arg) 291 { 292 if (!handle_implicit_call(icall)) { 293 async_answer_0(icall, ENOTSUP); 294 return; 295 } 296 276 } 277 278 /* handle accepted calls */ 297 279 while (true) { 298 280 ipc_call_t call; 299 281 300 if (!async_get_call(&call) || !ipc_get_imethod(&call)) {282 if (!async_get_call(&call)) { 301 283 /* Client disconnected */ 302 break;284 return; 303 285 } 304 286 305 if (!handle_implicit_call(&call)) { 306 async_answer_0(icall, ENOTSUP); 307 break; 287 switch (ipc_get_imethod(&call)) { 288 case TASKMAN_I_AM_NS: 289 taskman_i_am_ns(&call); 290 break; 291 case TASKMAN_WAIT: 292 taskman_ctl_wait(&call); 293 break; 294 case TASKMAN_RETVAL: 295 taskman_ctl_retval(&call); 296 break; 297 case TASKMAN_EVENT_CALLBACK: 298 taskman_ctl_ev_callback(&call); 299 break; 300 default: 301 async_answer_0(&call, ENOTSUP); 308 302 } 309 }310 }311 312 static void taskman_connection(ipc_call_t *icall, void *arg)313 {314 /*315 * We don't expect (yet) clients to connect, having this function is316 * just to adapt to async framework that creates new connection for317 * each IPC_M_CONNECT_ME_TO.318 * In this case those are to be forwarded, so don't continue319 * "listening" on such connections.320 */321 if (!handle_implicit_call(icall)) {322 /* If cannot handle connection request, give up trying */323 async_answer_0(icall, EHANGUP);324 return;325 303 } 326 304 } … … 360 338 361 339 /* Start sysman server */ 362 async_set_implicit_connection(implicit_connection);363 340 async_set_fallback_port_handler(taskman_connection, NULL); 364 341
Note:
See TracChangeset
for help on using the changeset viewer.