Changeset 5fb32c5 in mainline for uspace/lib/c/generic/async.c
- Timestamp:
- 2011-08-20T09:05:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c916dfc
- Parents:
- 921b84f (diff), a0fc4be (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
r921b84f r5fb32c5 98 98 #include <ipc/ipc.h> 99 99 #include <async.h> 100 #include "private/async.h" 100 101 #undef LIBC_ASYNC_C_ 101 102 … … 113 114 #include <stdlib.h> 114 115 #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 998 1001 list_initialize(&session_ns->exch_list); 999 1002 fibril_mutex_initialize(&session_ns->mutex); … … 1472 1475 return ENOENT; 1473 1476 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 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); 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); 1480 1485 if (rc != EOK) 1481 return rc;1482 1483 task_id = (task_id_t) MERGE_LOUP32(task_id_lo, task_id_hi);1484 1486 return (int) rc; 1487 1488 phone_hash = IPC_GET_ARG5(answer); 1489 1485 1490 if (client_receiver != NULL) 1486 async_new_connection( task_id, phone_hash, 0, NULL,1491 async_new_connection(answer.in_task_id, phone_hash, 0, NULL, 1487 1492 client_receiver, carg); 1488 1493 … … 1559 1564 sess->arg3 = 0; 1560 1565 1566 fibril_mutex_initialize(&sess->remote_state_mtx); 1567 sess->remote_state_data = NULL; 1568 1561 1569 list_initialize(&sess->exch_list); 1562 1570 fibril_mutex_initialize(&sess->mutex); … … 1640 1648 sess->arg3 = arg3; 1641 1649 1650 fibril_mutex_initialize(&sess->remote_state_mtx); 1651 sess->remote_state_data = NULL; 1652 1642 1653 list_initialize(&sess->exch_list); 1643 1654 fibril_mutex_initialize(&sess->mutex); … … 1690 1701 sess->arg3 = arg3; 1691 1702 1703 fibril_mutex_initialize(&sess->remote_state_mtx); 1704 sess->remote_state_data = NULL; 1705 1692 1706 list_initialize(&sess->exch_list); 1693 1707 fibril_mutex_initialize(&sess->mutex); … … 1720 1734 sess->arg2 = 0; 1721 1735 sess->arg3 = 0; 1736 1737 fibril_mutex_initialize(&sess->remote_state_mtx); 1738 sess->remote_state_data = NULL; 1722 1739 1723 1740 list_initialize(&sess->exch_list); … … 2384 2401 sess->arg3 = 0; 2385 2402 2403 fibril_mutex_initialize(&sess->remote_state_mtx); 2404 sess->remote_state_data = NULL; 2405 2386 2406 list_initialize(&sess->exch_list); 2387 2407 fibril_mutex_initialize(&sess->mutex); … … 2430 2450 sess->arg3 = 0; 2431 2451 2452 fibril_mutex_initialize(&sess->remote_state_mtx); 2453 sess->remote_state_data = NULL; 2454 2432 2455 list_initialize(&sess->exch_list); 2433 2456 fibril_mutex_initialize(&sess->mutex); … … 2471 2494 sess->arg2 = 0; 2472 2495 sess->arg3 = 0; 2496 2497 fibril_mutex_initialize(&sess->remote_state_mtx); 2498 sess->remote_state_data = NULL; 2473 2499 2474 2500 list_initialize(&sess->exch_list); … … 2512 2538 } 2513 2539 2540 /** Lock and get session remote state 2541 * 2542 * Lock and get the local replica of the remote state 2543 * in stateful sessions. The call should be paired 2544 * with async_remote_state_release*(). 2545 * 2546 * @param[in] sess Stateful session. 2547 * 2548 * @return Local replica of the remote state. 2549 * 2550 */ 2551 void *async_remote_state_acquire(async_sess_t *sess) 2552 { 2553 fibril_mutex_lock(&sess->remote_state_mtx); 2554 return sess->remote_state_data; 2555 } 2556 2557 /** Update the session remote state 2558 * 2559 * Update the local replica of the remote state 2560 * in stateful sessions. The remote state must 2561 * be already locked. 2562 * 2563 * @param[in] sess Stateful session. 2564 * @param[in] state New local replica of the remote state. 2565 * 2566 */ 2567 void async_remote_state_update(async_sess_t *sess, void *state) 2568 { 2569 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2570 sess->remote_state_data = state; 2571 } 2572 2573 /** Release the session remote state 2574 * 2575 * Unlock the local replica of the remote state 2576 * in stateful sessions. 2577 * 2578 * @param[in] sess Stateful session. 2579 * 2580 */ 2581 void async_remote_state_release(async_sess_t *sess) 2582 { 2583 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2584 2585 fibril_mutex_unlock(&sess->remote_state_mtx); 2586 } 2587 2588 /** Release the session remote state and end an exchange 2589 * 2590 * Unlock the local replica of the remote state 2591 * in stateful sessions. This is convenience function 2592 * which gets the session pointer from the exchange 2593 * and also ends the exchange. 2594 * 2595 * @param[in] exch Stateful session's exchange. 2596 * 2597 */ 2598 void async_remote_state_release_exchange(async_exch_t *exch) 2599 { 2600 if (exch == NULL) 2601 return; 2602 2603 async_sess_t *sess = exch->sess; 2604 assert(fibril_mutex_is_locked(&sess->remote_state_mtx)); 2605 2606 async_exchange_end(exch); 2607 fibril_mutex_unlock(&sess->remote_state_mtx); 2608 } 2609 2514 2610 /** @} 2515 2611 */
Note:
See TracChangeset
for help on using the changeset viewer.