Changeset 53ca318 in mainline for libc/generic/async.c
- Timestamp:
- 2006-05-23T11:01:31Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8c6b45f
- Parents:
- 07d960a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libc/generic/async.c
r07d960a r53ca318 61 61 * 2) Multithreaded server application 62 62 * main() { 63 * wait_for_connection(new_connection);63 * async_manager(); 64 64 * } 65 65 * 66 66 * 67 * new_connection(int connection) { 68 * accept(connection); 69 * msg = get_msg(); 70 * handle(msg); 71 * answer(msg); 72 * 73 * msg = get_msg(); 67 * client_connection(icallid, *icall) { 68 * if (want_refuse) { 69 * ipc_answer_fast(icallid, ELIMIT, 0, 0); 70 * return; 71 * } 72 * ipc_answer_fast(icallid, 0, 0, 0); 73 * 74 * callid = async_get_call(&call); 75 * handle(callid, call); 76 * ipc_answer_fast(callid, 1,2,3); 77 * 78 * callid = async_get_call(&call); 74 79 * .... 75 80 * } … … 105 110 ipc_callid_t callid; 106 111 ipc_call_t call; 112 void (*cthread)(ipc_callid_t,ipc_call_t *); 107 113 } connection_t; 108 114 … … 226 232 /* Setup thread local connection pointer */ 227 233 PS_connection = (connection_t *)arg; 228 client_connection(PS_connection->callid, &PS_connection->call);234 PS_connection->cthread(PS_connection->callid, &PS_connection->call); 229 235 230 236 /* Remove myself from connection hash table */ … … 248 254 * later we can easily do routing of messages to particular 249 255 * threads. 250 */ 251 static void new_connection(ipc_callid_t callid, ipc_call_t *call) 256 * 257 * @param callid Callid of the IPC_M_CONNECT_ME_TO packet 258 * @param call Call data of the opening packet 259 * @param cthread Thread function that should be called upon 260 * opening the connection 261 * @return New thread id 262 */ 263 pstid_t async_new_connection(ipc_callid_t callid, ipc_call_t *call, 264 void (*cthread)(ipc_callid_t,ipc_call_t *)) 252 265 { 253 266 pstid_t ptid; … … 258 271 if (!conn) { 259 272 ipc_answer_fast(callid, ENOMEM, 0, 0); 260 return ;273 return NULL; 261 274 } 262 275 conn->in_phone_hash = IPC_GET_ARG3(*call); … … 266 279 conn->call = *call; 267 280 conn->active = 1; /* We will activate it asap */ 281 conn->cthread = cthread; 268 282 list_initialize(&conn->link); 269 283 if (!conn->ptid) { 270 284 free(conn); 271 285 ipc_answer_fast(callid, ENOMEM, 0, 0); 272 return ;286 return NULL; 273 287 } 274 288 key = conn->in_phone_hash; … … 279 293 280 294 psthread_add_ready(conn->ptid); 295 296 return conn->ptid; 281 297 } 282 298 … … 292 308 case IPC_M_CONNECT_ME_TO: 293 309 /* Open new connection with thread etc. */ 294 new_connection(callid, call);310 async_new_connection(callid, call, client_connection); 295 311 break; 296 312 default:
Note:
See TracChangeset
for help on using the changeset viewer.