Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/async.c

    r36e2b55 r649f087  
    9898#include <ipc/ipc.h>
    9999#include <async.h>
    100 #include "private/async.h"
    101100#undef LIBC_ASYNC_C_
    102101
     
    114113#include <stdlib.h>
    115114#include <macros.h>
     115#include "private/async.h"
    116116
    117117#define CLIENT_HASH_TABLE_BUCKETS  32
     
    996996        session_ns->arg3 = 0;
    997997       
    998         fibril_mutex_initialize(&session_ns->remote_state_mtx);
    999         session_ns->remote_state_data = NULL;
    1000        
    1001998        list_initialize(&session_ns->exch_list);
    1002999        fibril_mutex_initialize(&session_ns->mutex);
     
    14751472                return ENOENT;
    14761473       
     1474        task_id_t task_id;
     1475        sysarg_t task_id_lo;
     1476        sysarg_t task_id_hi;
    14771477        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);
    14851480        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       
    14901485        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,
    14921487                    client_receiver, carg);
    14931488       
     
    15641559        sess->arg3 = 0;
    15651560       
    1566         fibril_mutex_initialize(&sess->remote_state_mtx);
    1567         sess->remote_state_data = NULL;
    1568        
    15691561        list_initialize(&sess->exch_list);
    15701562        fibril_mutex_initialize(&sess->mutex);
     
    16481640        sess->arg3 = arg3;
    16491641       
    1650         fibril_mutex_initialize(&sess->remote_state_mtx);
    1651         sess->remote_state_data = NULL;
    1652        
    16531642        list_initialize(&sess->exch_list);
    16541643        fibril_mutex_initialize(&sess->mutex);
     
    16561645       
    16571646        return sess;
    1658 }
    1659 
    1660 /** Set arguments for new connections.
    1661  *
    1662  * FIXME This is an ugly hack to work around the problem that parallel
    1663  * exchanges are implemented using parallel connections. When we create
    1664  * a callback session, the framework does not know arguments for the new
    1665  * connections.
    1666  *
    1667  * The proper solution seems to be to implement parallel exchanges using
    1668  * 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;
    16761647}
    16771648
     
    17191690        sess->arg3 = arg3;
    17201691       
    1721         fibril_mutex_initialize(&sess->remote_state_mtx);
    1722         sess->remote_state_data = NULL;
    1723        
    17241692        list_initialize(&sess->exch_list);
    17251693        fibril_mutex_initialize(&sess->mutex);
     
    17531721        sess->arg3 = 0;
    17541722       
    1755         fibril_mutex_initialize(&sess->remote_state_mtx);
    1756         sess->remote_state_data = NULL;
    1757        
    17581723        list_initialize(&sess->exch_list);
    17591724        fibril_mutex_initialize(&sess->mutex);
     
    17771742int async_hangup(async_sess_t *sess)
    17781743{
    1779         async_exch_t *exch;
    1780        
    17811744        assert(sess);
    17821745       
    17831746        if (atomic_get(&sess->refcnt) > 0)
    17841747                return EBUSY;
    1785        
    1786         fibril_mutex_lock(&async_sess_mutex);
    17871748       
    17881749        int rc = async_hangup_internal(sess->phone);
    17891750        if (rc == EOK)
    17901751                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);
    18041752       
    18051753        return rc;
     
    24362384        sess->arg3 = 0;
    24372385       
    2438         fibril_mutex_initialize(&sess->remote_state_mtx);
    2439         sess->remote_state_data = NULL;
    2440        
    24412386        list_initialize(&sess->exch_list);
    24422387        fibril_mutex_initialize(&sess->mutex);
     
    24852430        sess->arg3 = 0;
    24862431       
    2487         fibril_mutex_initialize(&sess->remote_state_mtx);
    2488         sess->remote_state_data = NULL;
    2489        
    24902432        list_initialize(&sess->exch_list);
    24912433        fibril_mutex_initialize(&sess->mutex);
     
    25292471        sess->arg2 = 0;
    25302472        sess->arg3 = 0;
    2531        
    2532         fibril_mutex_initialize(&sess->remote_state_mtx);
    2533         sess->remote_state_data = NULL;
    25342473       
    25352474        list_initialize(&sess->exch_list);
     
    25732512}
    25742513
    2575 /** Lock and get session remote state
    2576  *
    2577  * Lock and get the local replica of the remote state
    2578  * in stateful sessions. The call should be paired
    2579  * 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 state
    2593  *
    2594  * Update the local replica of the remote state
    2595  * in stateful sessions. The remote state must
    2596  * 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 state
    2609  *
    2610  * Unlock the local replica of the remote state
    2611  * 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 exchange
    2624  *
    2625  * Unlock the local replica of the remote state
    2626  * in stateful sessions. This is convenience function
    2627  * which gets the session pointer from the exchange
    2628  * 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 
    26452514/** @}
    26462515 */
Note: See TracChangeset for help on using the changeset viewer.