Changes in uspace/lib/c/generic/async_sess.c [8cd21d16:8b5c8ae] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/async_sess.c
r8cd21d16 r8b5c8ae 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; … … 128 129 */ 129 130 static LIST_INITIALIZE(session_list_head); 131 132 /** 133 * Condition variable used to wait for a phone to become available. 134 */ 135 static FIBRIL_CONDVAR_INITIALIZE(avail_phone_cv); 130 136 131 137 /** Initialize the async_sess subsystem. … … 150 156 * @param sess Session structure provided by caller, will be filled in. 151 157 * @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 */ 163 void async_session_create(async_sess_t *sess, int phone, sysarg_t arg1) 154 164 { 155 165 sess->sess_phone = phone; 166 sess->connect_arg1 = arg1; 156 167 list_initialize(&sess->conn_head); 157 168 … … 192 203 free(conn); 193 204 } 205 206 fibril_condvar_broadcast(&avail_phone_cv); 194 207 } 195 208 … … 231 244 */ 232 245 retry: 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); 234 248 if (data_phone >= 0) { 235 249 /* success, do nothing */ … … 250 264 } else { 251 265 /* 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. 256 267 */ 257 data_phone = ELIMIT; 268 fibril_condvar_wait(&avail_phone_cv, &async_sess_mutex); 269 goto retry; 258 270 } 259 271 } … … 273 285 274 286 fibril_mutex_lock(&async_sess_mutex); 287 fibril_condvar_signal(&avail_phone_cv); 275 288 conn = (conn_node_t *) malloc(sizeof(conn_node_t)); 276 289 if (!conn) { … … 279 292 * means that we simply hang up. 280 293 */ 294 ipc_hangup(data_phone); 281 295 fibril_mutex_unlock(&async_sess_mutex); 282 ipc_hangup(data_phone);283 296 return; 284 297 }
Note:
See TracChangeset
for help on using the changeset viewer.