Changeset 8b5690f in mainline for uspace/lib/c/generic/async_sess.c
- Timestamp:
- 2011-02-03T05:11:01Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba38f72c
- Parents:
- 22027b6e (diff), 86d7bfa (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_sess.c
r22027b6e r8b5690f 99 99 100 100 #include <async_sess.h> 101 #include <ipc/ipc.h>102 101 #include <fibril_synch.h> 103 102 #include <adt/list.h> … … 106 105 #include <errno.h> 107 106 #include <assert.h> 107 #include "private/async_sess.h" 108 108 109 109 /** An inactive open connection. */ 110 110 typedef struct { 111 111 link_t sess_link; /**< Link for the session list of inactive connections. */ 112 link_t global_link; /**< Link for the global list of inactive connecti nos. */112 link_t global_link; /**< Link for the global list of inactive connections. */ 113 113 int data_phone; /**< Connected data phone. */ 114 114 } conn_node_t; 115 115 116 116 /** 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. 118 119 */ 119 120 static fibril_mutex_t async_sess_mutex; … … 129 130 static LIST_INITIALIZE(session_list_head); 130 131 132 /** 133 * Condition variable used to wait for a phone to become available. 134 */ 135 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv); 136 131 137 /** Initialize the async_sess subsystem. 132 138 * 133 139 * Needs to be called prior to any other interface in this file. 134 */ 135 void _async_sess_init(void) 140 * 141 */ 142 void __async_sess_init(void) 136 143 { 137 144 fibril_mutex_initialize(&async_sess_mutex); … … 194 201 list_remove(&conn->global_link); 195 202 196 ipc_hangup(conn->data_phone);203 async_hangup(conn->data_phone); 197 204 free(conn); 198 205 } 206 207 fibril_condvar_broadcast(&avail_phone_cv); 199 208 } 200 209 … … 252 261 data_phone = conn->data_phone; 253 262 free(conn); 254 ipc_hangup(data_phone);263 async_hangup(data_phone); 255 264 goto retry; 256 265 } else { 257 266 /* 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). 267 * Wait for a phone to become available. 262 268 */ 263 data_phone = ELIMIT; 269 fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex); 270 goto retry; 264 271 } 265 272 } … … 279 286 280 287 fibril_mutex_lock(&async_sess_mutex); 288 fibril_condvar_signal(&avail_phone_cv); 281 289 conn = (conn_node_t *) malloc(sizeof(conn_node_t)); 282 290 if (!conn) { … … 285 293 * means that we simply hang up. 286 294 */ 295 async_hangup(data_phone); 287 296 fibril_mutex_unlock(&async_sess_mutex); 288 ipc_hangup(data_phone);289 297 return; 290 298 }
Note:
See TracChangeset
for help on using the changeset viewer.