Changes in uspace/lib/c/generic/async.c [36e2b55:649f087] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async.c
r36e2b55 r649f087 98 98 #include <ipc/ipc.h> 99 99 #include <async.h> 100 #include "private/async.h"101 100 #undef LIBC_ASYNC_C_ 102 101 … … 114 113 #include <stdlib.h> 115 114 #include <macros.h> 115 #include "private/async.h" 116 116 117 117 #define CLIENT_HASH_TABLE_BUCKETS 32 … … 996 996 session_ns->arg3 = 0; 997 997 998 fibril_mutex_initialize(&session_ns->remote_state_mtx);999 session_ns->remote_state_data = NULL;1000 1001 998 list_initialize(&session_ns->exch_list); 1002 999 fibril_mutex_initialize(&session_ns->mutex); … … 1475 1472 return ENOENT; 1476 1473 1474 task_id_t task_id; 1475 sysarg_t task_id_lo; 1476 sysarg_t task_id_hi; 1477 1477 sysarg_t phone_hash; 1478 sysarg_t rc; 1479 1480 aid_t req; 1481 ipc_call_t answer; 1482 req = async_send_3(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1483 &answer); 1484 async_wait_for(req, &rc); 1478 int rc = async_req_3_5(exch, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1479 NULL, NULL, &task_id_lo, &task_id_hi, &phone_hash); 1485 1480 if (rc != EOK) 1486 return (int)rc;1487 1488 phone_hash = IPC_GET_ARG5(answer);1489 1481 return rc; 1482 1483 task_id = (task_id_t) MERGE_LOUP32(task_id_lo, task_id_hi); 1484 1490 1485 if (client_receiver != NULL) 1491 async_new_connection( answer.in_task_id, phone_hash, 0, NULL,1486 async_new_connection(task_id, phone_hash, 0, NULL, 1492 1487 client_receiver, carg); 1493 1488 … … 1564 1559 sess->arg3 = 0; 1565 1560 1566 fibril_mutex_initialize(&sess->remote_state_mtx);1567 sess->remote_state_data = NULL;1568 1569 1561 list_initialize(&sess->exch_list); 1570 1562 fibril_mutex_initialize(&sess->mutex); … … 1648 1640 sess->arg3 = arg3; 1649 1641 1650 fibril_mutex_initialize(&sess->remote_state_mtx);1651 sess->remote_state_data = NULL;1652 1653 1642 list_initialize(&sess->exch_list); 1654 1643 fibril_mutex_initialize(&sess->mutex); … … 1656 1645 1657 1646 return sess; 1658 }1659 1660 /** Set arguments for new connections.1661 *1662 * FIXME This is an ugly hack to work around the problem that parallel1663 * exchanges are implemented using parallel connections. When we create1664 * a callback session, the framework does not know arguments for the new1665 * connections.1666 *1667 * The proper solution seems to be to implement parallel exchanges using1668 * tagging.1669 */1670 void async_sess_args_set(async_sess_t *sess, sysarg_t arg1, sysarg_t arg2,1671 sysarg_t arg3)1672 {1673 sess->arg1 = arg1;1674 sess->arg2 = arg2;1675 sess->arg3 = arg3;1676 1647 } 1677 1648 … … 1719 1690 sess->arg3 = arg3; 1720 1691 1721 fibril_mutex_initialize(&sess->remote_state_mtx);1722 sess->remote_state_data = NULL;1723 1724 1692 list_initialize(&sess->exch_list); 1725 1693 fibril_mutex_initialize(&sess->mutex); … … 1753 1721 sess->arg3 = 0; 1754 1722 1755 fibril_mutex_initialize(&sess->remote_state_mtx);1756 sess->remote_state_data = NULL;1757 1758 1723 list_initialize(&sess->exch_list); 1759 1724 fibril_mutex_initialize(&sess->mutex); … … 1777 1742 int async_hangup(async_sess_t *sess) 1778 1743 { 1779 async_exch_t *exch;1780 1781 1744 assert(sess); 1782 1745 1783 1746 if (atomic_get(&sess->refcnt) > 0) 1784 1747 return EBUSY; 1785 1786 fibril_mutex_lock(&async_sess_mutex);1787 1748 1788 1749 int rc = async_hangup_internal(sess->phone); 1789 1750 if (rc == EOK) 1790 1751 free(sess); 1791 1792 while (!list_empty(&sess->exch_list)) {1793 exch = (async_exch_t *)1794 list_get_instance(list_first(&sess->exch_list),1795 async_exch_t, sess_link);1796 1797 list_remove(&exch->sess_link);1798 list_remove(&exch->global_link);1799 async_hangup_internal(exch->phone);1800 free(exch);1801 }1802 1803 fibril_mutex_unlock(&async_sess_mutex);1804 1752 1805 1753 return rc; … … 2436 2384 sess->arg3 = 0; 2437 2385 2438 fibril_mutex_initialize(&sess->remote_state_mtx);2439 sess->remote_state_data = NULL;2440 2441 2386 list_initialize(&sess->exch_list); 2442 2387 fibril_mutex_initialize(&sess->mutex); … … 2485 2430 sess->arg3 = 0; 2486 2431 2487 fibril_mutex_initialize(&sess->remote_state_mtx);2488 sess->remote_state_data = NULL;2489 2490 2432 list_initialize(&sess->exch_list); 2491 2433 fibril_mutex_initialize(&sess->mutex); … … 2529 2471 sess->arg2 = 0; 2530 2472 sess->arg3 = 0; 2531 2532 fibril_mutex_initialize(&sess->remote_state_mtx);2533 sess->remote_state_data = NULL;2534 2473 2535 2474 list_initialize(&sess->exch_list); … … 2573 2512 } 2574 2513 2575 /** Lock and get session remote state2576 *2577 * Lock and get the local replica of the remote state2578 * in stateful sessions. The call should be paired2579 * with async_remote_state_release*().2580 *2581 * @param[in] sess Stateful session.2582 *2583 * @return Local replica of the remote state.2584 *2585 */2586 void *async_remote_state_acquire(async_sess_t *sess)2587 {2588 fibril_mutex_lock(&sess->remote_state_mtx);2589 return sess->remote_state_data;2590 }2591 2592 /** Update the session remote state2593 *2594 * Update the local replica of the remote state2595 * in stateful sessions. The remote state must2596 * be already locked.2597 *2598 * @param[in] sess Stateful session.2599 * @param[in] state New local replica of the remote state.2600 *2601 */2602 void async_remote_state_update(async_sess_t *sess, void *state)2603 {2604 assert(fibril_mutex_is_locked(&sess->remote_state_mtx));2605 sess->remote_state_data = state;2606 }2607 2608 /** Release the session remote state2609 *2610 * Unlock the local replica of the remote state2611 * in stateful sessions.2612 *2613 * @param[in] sess Stateful session.2614 *2615 */2616 void async_remote_state_release(async_sess_t *sess)2617 {2618 assert(fibril_mutex_is_locked(&sess->remote_state_mtx));2619 2620 fibril_mutex_unlock(&sess->remote_state_mtx);2621 }2622 2623 /** Release the session remote state and end an exchange2624 *2625 * Unlock the local replica of the remote state2626 * in stateful sessions. This is convenience function2627 * which gets the session pointer from the exchange2628 * and also ends the exchange.2629 *2630 * @param[in] exch Stateful session's exchange.2631 *2632 */2633 void async_remote_state_release_exchange(async_exch_t *exch)2634 {2635 if (exch == NULL)2636 return;2637 2638 async_sess_t *sess = exch->sess;2639 assert(fibril_mutex_is_locked(&sess->remote_state_mtx));2640 2641 async_exchange_end(exch);2642 fibril_mutex_unlock(&sess->remote_state_mtx);2643 }2644 2645 2514 /** @} 2646 2515 */
Note:
See TracChangeset
for help on using the changeset viewer.