Changeset 8b5c8ae in mainline


Ignore:
Timestamp:
2011-01-09T20:44:24Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
622dea8
Parents:
80bffdb0
Message:

If there are no available phones to be used by the async sessions
framework, sleep on a condition variable until a phone becomes
available.

File:
1 edited

Legend:

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

    r80bffdb0 r8b5c8ae  
    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.
     
    197203                free(conn);
    198204        }
     205       
     206        fibril_condvar_broadcast(&avail_phone_cv);
    199207}
    200208
     
    256264                } else {
    257265                        /*
    258                          * This is unfortunate. We failed both to find a cached
    259                          * connection or to create a new one even after cleaning up
    260                          * the cache. This is most likely due to too many
    261                          * open sessions (connected session phones).
     266                         * Wait for a phone to become available.
    262267                         */
    263                         data_phone = ELIMIT;
     268                        fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex);
     269                        goto retry;
    264270                }
    265271        }
     
    279285
    280286        fibril_mutex_lock(&async_sess_mutex);
     287        fibril_condvar_signal(&avail_phone_cv);
    281288        conn = (conn_node_t *) malloc(sizeof(conn_node_t));
    282289        if (!conn) {
     
    285292                 * means that we simply hang up.
    286293                 */
     294                ipc_hangup(data_phone);
    287295                fibril_mutex_unlock(&async_sess_mutex);
    288                 ipc_hangup(data_phone);
    289296                return;
    290297        }
Note: See TracChangeset for help on using the changeset viewer.