Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 58cbf8d5 in mainline


Ignore:
Timestamp:
2011-08-19T18:51:05Z (10 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
e3e4a2c
Parents:
7b2a7ad
Message:

basic support for tracking a client replica of the remote state in stateful protocols

Location:
uspace/lib/c
Files:
3 edited

Legend:

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

    r7b2a7ad r58cbf8d5  
    996996        session_ns->arg3 = 0;
    997997       
     998        fibril_mutex_initialize(&session_ns->remote_state_mtx);
     999        session_ns->remote_state_data = NULL;
     1000       
    9981001        list_initialize(&session_ns->exch_list);
    9991002        fibril_mutex_initialize(&session_ns->mutex);
     
    15611564        sess->arg3 = 0;
    15621565       
     1566        fibril_mutex_initialize(&sess->remote_state_mtx);
     1567        sess->remote_state_data = NULL;
     1568       
    15631569        list_initialize(&sess->exch_list);
    15641570        fibril_mutex_initialize(&sess->mutex);
     
    16421648        sess->arg3 = arg3;
    16431649       
     1650        fibril_mutex_initialize(&sess->remote_state_mtx);
     1651        sess->remote_state_data = NULL;
     1652       
    16441653        list_initialize(&sess->exch_list);
    16451654        fibril_mutex_initialize(&sess->mutex);
     
    16921701        sess->arg3 = arg3;
    16931702       
     1703        fibril_mutex_initialize(&sess->remote_state_mtx);
     1704        sess->remote_state_data = NULL;
     1705       
    16941706        list_initialize(&sess->exch_list);
    16951707        fibril_mutex_initialize(&sess->mutex);
     
    17221734        sess->arg2 = 0;
    17231735        sess->arg3 = 0;
     1736       
     1737        fibril_mutex_initialize(&sess->remote_state_mtx);
     1738        sess->remote_state_data = NULL;
    17241739       
    17251740        list_initialize(&sess->exch_list);
     
    23862401        sess->arg3 = 0;
    23872402       
     2403        fibril_mutex_initialize(&sess->remote_state_mtx);
     2404        sess->remote_state_data = NULL;
     2405       
    23882406        list_initialize(&sess->exch_list);
    23892407        fibril_mutex_initialize(&sess->mutex);
     
    24322450        sess->arg3 = 0;
    24332451       
     2452        fibril_mutex_initialize(&sess->remote_state_mtx);
     2453        sess->remote_state_data = NULL;
     2454       
    24342455        list_initialize(&sess->exch_list);
    24352456        fibril_mutex_initialize(&sess->mutex);
     
    24732494        sess->arg2 = 0;
    24742495        sess->arg3 = 0;
     2496       
     2497        fibril_mutex_initialize(&sess->remote_state_mtx);
     2498        sess->remote_state_data = NULL;
    24752499       
    24762500        list_initialize(&sess->exch_list);
     
    25142538}
    25152539
     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 */
     2551void *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 */
     2567void 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 */
     2581void 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 */
     2598void 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
    25162610/** @}
    25172611 */
  • uspace/lib/c/generic/private/async.h

    r7b2a7ad r58cbf8d5  
    6868        /** Number of opened exchanges */
    6969        atomic_t refcnt;
     70       
     71        /** Mutex for stateful connections */
     72        fibril_mutex_t remote_state_mtx;
     73       
     74        /** Data for stateful connections */
     75        void *remote_state_data;
    7076};
    7177
  • uspace/lib/c/include/async.h

    r7b2a7ad r58cbf8d5  
    449449extern int async_state_change_finalize(ipc_callid_t, async_exch_t *);
    450450
     451extern void *async_remote_state_acquire(async_sess_t *);
     452extern void async_remote_state_update(async_sess_t *, void *);
     453extern void async_remote_state_release(async_sess_t *);
     454extern void async_remote_state_release_exchange(async_exch_t *);
     455
    451456#endif
    452457
Note: See TracChangeset for help on using the changeset viewer.