Changeset e4f8c77 in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2011-07-13T22:39:18Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e6910c8
- Parents:
- 5974661 (diff), 8ecef91 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r5974661 re4f8c77 160 160 161 161 /** Messages that should be delivered to this fibril. */ 162 li nk_t msg_queue;162 list_t msg_queue; 163 163 164 164 /** Identification of the opening call. */ … … 166 166 /** Call data of the opening call. */ 167 167 ipc_call_t call; 168 /** Local argument or NULL if none. */ 169 void *carg; 168 170 169 171 /** Identification of the closing call. */ … … 171 173 172 174 /** Fibril function that will be used to handle the connection. */ 173 void (*cfibril)(ipc_callid_t, ipc_call_t *);175 async_client_conn_t cfibril; 174 176 } connection_t; 175 177 … … 213 215 * @param callid Hash of the incoming call. 214 216 * @param call Data of the incoming call. 215 * 216 */ 217 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call) 217 * @param arg Local argument 218 * 219 */ 220 static void default_client_connection(ipc_callid_t callid, ipc_call_t *call, 221 void *arg) 218 222 { 219 223 ipc_answer_0(callid, ENOENT); … … 226 230 * @param callid Hash of the incoming call. 227 231 * @param call Data of the incoming call. 232 * @param arg Local argument. 228 233 * 229 234 */ … … 233 238 234 239 static async_client_conn_t client_connection = default_client_connection; 235 static async_ client_conn_t interrupt_received = default_interrupt_received;240 static async_interrupt_handler_t interrupt_received = default_interrupt_received; 236 241 237 242 /** Setter for client_connection function pointer. … … 250 255 * notification fibril. 251 256 */ 252 void async_set_interrupt_received(async_ client_conn_t intr)257 void async_set_interrupt_received(async_interrupt_handler_t intr) 253 258 { 254 259 interrupt_received = intr; … … 356 361 wd->to_event.inlist = true; 357 362 358 link_t *tmp = timeout_list. next;359 while (tmp != &timeout_list ) {363 link_t *tmp = timeout_list.head.next; 364 while (tmp != &timeout_list.head) { 360 365 awaiter_t *cur 361 366 = list_get_instance(tmp, awaiter_t, to_event.link); … … 367 372 } 368 373 369 list_ append(&wd->to_event.link, tmp);374 list_insert_before(&wd->to_event.link, tmp); 370 375 } 371 376 … … 564 569 } 565 570 566 msg_t *msg = list_get_instance( conn->msg_queue.next, msg_t, link);571 msg_t *msg = list_get_instance(list_first(&conn->msg_queue), msg_t, link); 567 572 list_remove(&msg->link); 568 573 … … 633 638 */ 634 639 fibril_connection->cfibril(fibril_connection->callid, 635 &fibril_connection->call );640 &fibril_connection->call, fibril_connection->carg); 636 641 637 642 /* … … 670 675 while (!list_empty(&fibril_connection->msg_queue)) { 671 676 msg_t *msg = 672 list_get_instance( fibril_connection->msg_queue.next, msg_t,673 link);677 list_get_instance(list_first(&fibril_connection->msg_queue), 678 msg_t, link); 674 679 675 680 list_remove(&msg->link); … … 704 709 * @param cfibril Fibril function that should be called upon opening the 705 710 * connection. 711 * @param carg Extra argument to pass to the connection fibril 706 712 * 707 713 * @return New fibril id or NULL on failure. … … 710 716 fid_t async_new_connection(sysarg_t in_task_hash, sysarg_t in_phone_hash, 711 717 ipc_callid_t callid, ipc_call_t *call, 712 async_client_conn_t cfibril )718 async_client_conn_t cfibril, void *carg) 713 719 { 714 720 connection_t *conn = malloc(sizeof(*conn)); … … 725 731 conn->callid = callid; 726 732 conn->close_callid = 0; 733 conn->carg = carg; 727 734 728 735 if (call) … … 779 786 /* Open new connection with fibril, etc. */ 780 787 async_new_connection(call->in_task_hash, IPC_GET_ARG5(*call), 781 callid, call, client_connection );788 callid, call, client_connection, NULL); 782 789 return; 783 790 } … … 799 806 futex_down(&async_futex); 800 807 801 link_t *cur = timeout_list.next;802 while (cur != &timeout_list) {808 link_t *cur = list_first(&timeout_list); 809 while (cur != NULL) { 803 810 awaiter_t *waiter = 804 811 list_get_instance(cur, awaiter_t, to_event.link); … … 806 813 if (tv_gt(&waiter->to_event.expires, &tv)) 807 814 break; 808 809 cur = cur->next;810 815 811 816 list_remove(&waiter->to_event.link); … … 821 826 fibril_add_ready(waiter->fid); 822 827 } 828 829 cur = list_first(&timeout_list); 823 830 } 824 831 … … 847 854 suseconds_t timeout; 848 855 if (!list_empty(&timeout_list)) { 849 awaiter_t *waiter = list_get_instance( timeout_list.next,850 awaiter_t, to_event.link);856 awaiter_t *waiter = list_get_instance( 857 list_first(&timeout_list), awaiter_t, to_event.link); 851 858 852 859 struct timeval tv; … … 1414 1421 */ 1415 1422 int async_connect_to_me(async_exch_t *exch, sysarg_t arg1, sysarg_t arg2, 1416 sysarg_t arg3, async_client_conn_t client_receiver )1423 sysarg_t arg3, async_client_conn_t client_receiver, void *carg) 1417 1424 { 1418 1425 if (exch == NULL) … … 1428 1435 if (client_receiver != NULL) 1429 1436 async_new_connection(task_hash, phone_hash, 0, NULL, 1430 client_receiver );1437 client_receiver, carg); 1431 1438 1432 1439 return EOK; … … 1724 1731 */ 1725 1732 exch = (async_exch_t *) 1726 list_get_instance(sess->exch_list.next, async_exch_t, sess_link); 1733 list_get_instance(list_first(&sess->exch_list), 1734 async_exch_t, sess_link); 1735 1727 1736 list_remove(&exch->sess_link); 1728 1737 list_remove(&exch->global_link); … … 1736 1745 exch = (async_exch_t *) malloc(sizeof(async_exch_t)); 1737 1746 if (exch != NULL) { 1738 li st_initialize(&exch->sess_link);1739 li st_initialize(&exch->global_link);1747 link_initialize(&exch->sess_link); 1748 link_initialize(&exch->global_link); 1740 1749 exch->sess = sess; 1741 1750 exch->phone = sess->phone; … … 1754 1763 exch = (async_exch_t *) malloc(sizeof(async_exch_t)); 1755 1764 if (exch != NULL) { 1756 li st_initialize(&exch->sess_link);1757 li st_initialize(&exch->global_link);1765 link_initialize(&exch->sess_link); 1766 link_initialize(&exch->global_link); 1758 1767 exch->sess = sess; 1759 1768 exch->phone = phone; … … 1767 1776 */ 1768 1777 exch = (async_exch_t *) 1769 list_get_instance(inactive_exch_list.next, async_exch_t, 1770 global_link); 1778 list_get_instance(list_first(&inactive_exch_list), 1779 async_exch_t, global_link); 1780 1771 1781 list_remove(&exch->sess_link); 1772 1782 list_remove(&exch->global_link); … … 1808 1818 async_sess_t *sess = exch->sess; 1809 1819 1820 atomic_dec(&sess->refcnt); 1821 1810 1822 if (sess->mgmt == EXCHANGE_SERIALIZE) 1811 1823 fibril_mutex_unlock(&sess->mutex);
Note:
See TracChangeset
for help on using the changeset viewer.