Changeset 9db9b10 in mainline for uspace/lib/libc/generic/async.c
- Timestamp:
- 2009-06-03T19:16:07Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 937aeee
- Parents:
- e77994dd
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/libc/generic/async.c
re77994dd r9db9b10 179 179 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call); 180 180 static void default_interrupt_received(ipc_callid_t callid, ipc_call_t *call); 181 static void default_pending(void); 181 182 182 183 /** … … 191 192 static async_client_conn_t interrupt_received = default_interrupt_received; 192 193 194 /** 195 * Pointer to a fibril function that will be used to handle pending 196 * operations. 197 */ 198 static async_pending_t pending = default_pending; 193 199 194 200 static hash_table_t conn_hash_table; 195 201 static LIST_INITIALIZE(timeout_list); 196 197 202 198 203 #define CONN_HASH_TABLE_CHAINS 32 … … 371 376 372 377 fid_t fid = fibril_create(notification_fibril, msg); 378 fibril_add_ready(fid); 379 380 futex_up(&async_futex); 381 return true; 382 } 383 384 /** Pending fibril. 385 * 386 * After each call the pending operations are executed in a separate 387 * fibril. The function pending() is c. 388 * 389 * @param arg Unused. 390 * 391 * @return Always zero. 392 * 393 */ 394 static int pending_fibril(void *arg) 395 { 396 pending(); 397 398 return 0; 399 } 400 401 /** Process pending actions. 402 * 403 * A new fibril is created which would process the pending operations. 404 * 405 * @return False if an error occured. 406 * True if the execution was passed to the pending fibril. 407 * 408 */ 409 static bool process_pending(void) 410 { 411 futex_down(&async_futex); 412 413 fid_t fid = fibril_create(pending_fibril, NULL); 373 414 fibril_add_ready(fid); 374 415 … … 473 514 } 474 515 516 /** Default fibril function that gets called to handle pending operations. 517 * 518 * This function is defined as a weak symbol - to be redefined in user code. 519 * 520 */ 521 static void default_pending(void) 522 { 523 } 524 475 525 /** Wrapper for client connection fibril. 476 526 * … … 564 614 565 615 /* Add connection to the connection hash table */ 566 ipcarg_tkey = conn->in_phone_hash;616 unsigned long key = conn->in_phone_hash; 567 617 568 618 futex_down(&async_futex); … … 589 639 if ((callid & IPC_CALLID_NOTIFICATION)) { 590 640 process_notification(callid, call); 591 return;641 goto out; 592 642 } 593 643 … … 598 648 async_new_connection(IPC_GET_ARG5(*call), callid, call, 599 649 client_connection); 600 return;650 goto out; 601 651 } 602 652 603 653 /* Try to route the call through the connection hash table */ 604 654 if (route_call(callid, call)) 605 return;655 goto out; 606 656 607 657 /* Unknown call from unknown phone - hang it up */ 608 658 ipc_answer_0(callid, EHANGUP); 659 return; 660 661 out: 662 process_pending(); 609 663 } 610 664 … … 760 814 static void reply_received(void *arg, int retval, ipc_call_t *data) 761 815 { 816 futex_down(&async_futex); 817 762 818 amsg_t *msg = (amsg_t *) arg; 763 819 msg->retval = retval; 764 820 765 futex_down(&async_futex);766 767 821 /* Copy data after futex_down, just in case the call was detached */ 768 if ( msg->dataptr)822 if ((msg->dataptr) && (data)) 769 823 *msg->dataptr = *data; 770 824 … … 993 1047 { 994 1048 interrupt_received = intr; 1049 } 1050 1051 /** Setter for pending function pointer. 1052 * 1053 * @param pend Function that will implement a new pending 1054 * operations fibril. 1055 */ 1056 void async_set_pending(async_pending_t pend) 1057 { 1058 pending = pend; 995 1059 } 996 1060
Note:
See TracChangeset
for help on using the changeset viewer.