Changeset f401312 in mainline for uspace/lib/c/generic/async_sess.c


Ignore:
Timestamp:
2011-01-14T12:34:42Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
45019865
Parents:
b2a6fcfe (diff), 6610565b (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.
Message:

Merged development into lelian/hidd

File:
1 edited

Legend:

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

    rb2a6fcfe rf401312  
    110110typedef struct {
    111111        link_t sess_link;       /**< Link for the session list of inactive connections. */
    112         link_t global_link;     /**< Link for the global list of inactive connectinos. */
     112        link_t global_link;     /**< Link for the global list of inactive connections. */
    113113        int data_phone;         /**< Connected data phone. */
    114114} conn_node_t;
    115115
    116116/**
    117  * Mutex protecting the inactive_conn_head list and the session list.
     117 * Mutex protecting the inactive_conn_head list, the session list and the
     118 * avail_phone condition variable.
    118119 */
    119120static fibril_mutex_t async_sess_mutex;
     
    128129 */
    129130static LIST_INITIALIZE(session_list_head);
     131
     132/**
     133 * Condition variable used to wait for a phone to become available.
     134 */
     135static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv);
    130136
    131137/** Initialize the async_sess subsystem.
     
    150156 * @param sess  Session structure provided by caller, will be filled in.
    151157 * @param phone Phone connected to the desired server task.
    152  */
    153 void async_session_create(async_sess_t *sess, int phone)
     158 * @param arg1  Value to pass as first argument upon creating a new
     159 *              connection. Typical use is to identify a resource within
     160 *              the server that the caller wants to access (port ID,
     161 *              interface ID, device ID, etc.).
     162 */
     163void async_session_create(async_sess_t *sess, int phone, sysarg_t arg1)
    154164{
    155165        sess->sess_phone = phone;
     166        sess->connect_arg1 = arg1;
    156167        list_initialize(&sess->conn_head);
    157168       
     
    192203                free(conn);
    193204        }
     205       
     206        fibril_condvar_broadcast(&avail_phone_cv);
    194207}
    195208
     
    231244                 */
    232245retry:
    233                 data_phone = async_connect_me_to(sess->sess_phone, 0, 0, 0);
     246                data_phone = async_connect_me_to(sess->sess_phone,
     247                    sess->connect_arg1, 0, 0);
    234248                if (data_phone >= 0) {
    235249                        /* success, do nothing */
     
    250264                } else {
    251265                        /*
    252                          * This is unfortunate. We failed both to find a cached
    253                          * connection or to create a new one even after cleaning up
    254                          * the cache. This is most likely due to too many
    255                          * open sessions (connected session phones).
     266                         * Wait for a phone to become available.
    256267                         */
    257                         data_phone = ELIMIT;
     268                        fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex);
     269                        goto retry;
    258270                }
    259271        }
     
    273285
    274286        fibril_mutex_lock(&async_sess_mutex);
     287        fibril_condvar_signal(&avail_phone_cv);
    275288        conn = (conn_node_t *) malloc(sizeof(conn_node_t));
    276289        if (!conn) {
     
    279292                 * means that we simply hang up.
    280293                 */
     294                ipc_hangup(data_phone);
    281295                fibril_mutex_unlock(&async_sess_mutex);
    282                 ipc_hangup(data_phone);
    283296                return;
    284297        }
Note: See TracChangeset for help on using the changeset viewer.