Changeset b688fd8 in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2015-08-17T18:54:56Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- abf2dfd
- Parents:
- b10460a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
rb10460a rb688fd8 77 77 * } 78 78 * 79 * my_client_connection(icallid, *icall)79 * port_handler(icallid, *icall) 80 80 * { 81 81 * if (want_refuse) { … … 232 232 /** Identification of the opening call. */ 233 233 ipc_callid_t callid; 234 234 235 /** Call data of the opening call. */ 235 236 ipc_call_t call; 236 /** Local argument or NULL if none. */237 void *carg;238 237 239 238 /** Identification of the closing call. */ … … 241 240 242 241 /** Fibril function that will be used to handle the connection. */ 243 async_client_conn_t cfibril; 242 async_port_handler_t handler; 243 244 /** Client data */ 245 void *data; 244 246 } connection_t; 245 247 … … 335 337 } 336 338 337 /** Default fibril function that gets called to handle new connection. 338 * 339 * This function is defined as a weak symbol - to be redefined in user code. 339 /** Default fallback fibril function. 340 * 341 * This fallback fibril function gets called on incomming 342 * connections that do not have a specific handler defined. 340 343 * 341 344 * @param callid Hash of the incoming call. … … 344 347 * 345 348 */ 346 static void default_ client_connection(ipc_callid_t callid, ipc_call_t *call,349 static void default_fallback_port_handler(ipc_callid_t callid, ipc_call_t *call, 347 350 void *arg) 348 351 { … … 350 353 } 351 354 352 static async_client_conn_t client_connection = default_client_connection; 355 static async_port_handler_t fallback_port_handler = 356 default_fallback_port_handler; 357 static void *fallback_port_data = NULL; 358 353 359 static size_t notification_handler_stksz = FIBRIL_DFLT_STK_SIZE; 354 360 355 /** Setter for client_connection function pointer.356 *357 * @param conn Function that will implement a new connection fibril.358 *359 */360 void async_set_client_connection(async_client_conn_t conn)361 {362 assert(client_connection == default_client_connection);363 client_connection = conn;364 }365 366 361 /** Set the stack size for the notification handler notification fibrils. 367 362 * … … 387 382 */ 388 383 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv); 384 385 void async_set_fallback_port_handler(async_port_handler_t handler, void *data) 386 { 387 assert(handler != NULL); 388 389 fallback_port_handler = handler; 390 fallback_port_data = data; 391 } 389 392 390 393 static hash_table_t client_hash_table; … … 959 962 * 960 963 * When a new connection arrives, a fibril with this implementing function is 961 * created. It calls client_connection() and does the final cleanup.964 * created. It calls handler() and does the final cleanup. 962 965 * 963 966 * @param arg Connection structure pointer. … … 992 995 * Call the connection handler function. 993 996 */ 994 fibril_connection-> cfibril(fibril_connection->callid,995 &fibril_connection->call, fibril_connection-> carg);997 fibril_connection->handler(fibril_connection->callid, 998 &fibril_connection->call, fibril_connection->data); 996 999 997 1000 /* … … 1044 1047 * is called directly by the server. 1045 1048 * @param call Call data of the opening call. 1046 * @param cfibrilFibril function that should be called upon opening the1049 * @param handler Fibril function that should be called upon opening the 1047 1050 * connection. 1048 * @param cargExtra argument to pass to the connection fibril1051 * @param data Extra argument to pass to the connection fibril 1049 1052 * 1050 1053 * @return New fibril id or NULL on failure. … … 1053 1056 fid_t async_new_connection(task_id_t in_task_id, sysarg_t in_phone_hash, 1054 1057 ipc_callid_t callid, ipc_call_t *call, 1055 async_ client_conn_t cfibril, void *carg)1058 async_port_handler_t handler, void *data) 1056 1059 { 1057 1060 connection_t *conn = malloc(sizeof(*conn)); … … 1068 1071 conn->callid = callid; 1069 1072 conn->close_callid = 0; 1070 conn-> carg = carg;1073 conn->data = data; 1071 1074 1072 1075 if (call) … … 1075 1078 /* We will activate the fibril ASAP */ 1076 1079 conn->wdata.active = true; 1077 conn-> cfibril = cfibril;1080 conn->handler = handler; 1078 1081 conn->wdata.fid = fibril_create(connection_fibril, conn); 1079 1082 … … 1111 1114 assert(call); 1112 1115 1113 /* Unrouted call - take some default action */1116 /* Kernel notification */ 1114 1117 if ((callid & IPC_CALLID_NOTIFICATION)) { 1115 1118 process_notification(callid, call); … … 1122 1125 /* Open new connection with fibril, etc. */ 1123 1126 async_new_connection(call->in_task_id, IPC_GET_ARG5(*call), 1124 callid, call, client_connection, NULL);1127 callid, call, fallback_port_handler, fallback_port_data); 1125 1128 return; 1126 1129 } … … 1820 1823 */ 1821 1824 int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2, 1822 sysarg_t arg3, async_ client_conn_t client_receiver, void *carg)1825 sysarg_t arg3, async_port_handler_t client_receiver, void *data) 1823 1826 { 1824 1827 if (exch == NULL) … … 1840 1843 if (client_receiver != NULL) 1841 1844 async_new_connection(answer.in_task_id, phone_hash, 0, NULL, 1842 client_receiver, carg);1845 client_receiver, data); 1843 1846 1844 1847 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.