Changeset 261bbdc in mainline
- Timestamp:
- 2012-01-12T08:48:51Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 99c2e9f3
- Parents:
- 5923cf82
- Location:
- uspace/srv/hid/remcons
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/remcons/remcons.c
r5923cf82 r261bbdc 104 104 callid = async_get_call_timeout(&call, 1000); 105 105 106 fibril_mutex_lock(&user-> refcount_mutex);106 fibril_mutex_lock(&user->guard); 107 107 bool bail_out = user->socket_closed || user->task_finished; 108 fibril_mutex_unlock(&user-> refcount_mutex);108 fibril_mutex_unlock(&user->guard); 109 109 110 110 if (bail_out) { … … 134 134 int recv_length = recv(user->socket, user->socket_buffer, BUFFER_SIZE, 0); 135 135 if ((recv_length == 0) || (recv_length == ENOTCONN)) { 136 fibril_mutex_lock(&user-> refcount_mutex);136 fibril_mutex_lock(&user->guard); 137 137 user->socket_closed = true; 138 fibril_mutex_unlock(&user-> refcount_mutex);138 fibril_mutex_unlock(&user->guard); 139 139 async_answer_0(callid, ENOENT); 140 140 return; … … 283 283 telnet_user_error(user, "Spawning %s %s %s failed: %s.", 284 284 APP_GETTERM, term, "/app/bdsh", str_error(rc)); 285 fibril_mutex_lock(&user-> refcount_mutex);285 fibril_mutex_lock(&user->guard); 286 286 user->task_finished = true; 287 287 fibril_condvar_signal(&user->refcount_cv); 288 fibril_mutex_unlock(&user-> refcount_mutex);288 fibril_mutex_unlock(&user->guard); 289 289 return EOK; 290 290 } 291 291 292 fibril_mutex_lock(&user-> refcount_mutex);292 fibril_mutex_lock(&user->guard); 293 293 user->task_id = task; 294 fibril_mutex_unlock(&user-> refcount_mutex);294 fibril_mutex_unlock(&user->guard); 295 295 296 296 task_exit_t task_exit; … … 302 302 303 303 /* Announce destruction. */ 304 fibril_mutex_lock(&user-> refcount_mutex);304 fibril_mutex_lock(&user->guard); 305 305 user->task_finished = true; 306 306 fibril_condvar_signal(&user->refcount_cv); 307 fibril_mutex_unlock(&user-> refcount_mutex);307 fibril_mutex_unlock(&user->guard); 308 308 309 309 return EOK; … … 344 344 345 345 /* Wait for all clients to exit. */ 346 fibril_mutex_lock(&user-> refcount_mutex);346 fibril_mutex_lock(&user->guard); 347 347 while (!user_can_be_destroyed_no_lock(user)) { 348 348 if (user->task_finished) { … … 355 355 } 356 356 } 357 fibril_condvar_wait_timeout(&user->refcount_cv, &user-> refcount_mutex, 1000);358 } 359 fibril_mutex_unlock(&user-> refcount_mutex);357 fibril_condvar_wait_timeout(&user->refcount_cv, &user->guard, 1000); 358 } 359 fibril_mutex_unlock(&user->guard); 360 360 361 361 rc = loc_service_unregister(user->service_id); -
uspace/srv/hid/remcons/user.c
r5923cf82 r261bbdc 89 89 90 90 fibril_condvar_initialize(&user->refcount_cv); 91 fibril_mutex_initialize(&user-> refcount_mutex);91 fibril_mutex_initialize(&user->guard); 92 92 user->task_finished = false; 93 93 user->socket_closed = false; … … 139 139 140 140 telnet_user_t *tmp = user; 141 fibril_mutex_lock(&tmp-> refcount_mutex);141 fibril_mutex_lock(&tmp->guard); 142 142 user->locsrv_connection_count++; 143 143 … … 151 151 } 152 152 153 fibril_mutex_unlock(&tmp-> refcount_mutex);153 fibril_mutex_unlock(&tmp->guard); 154 154 155 155 … … 165 165 void telnet_user_notify_client_disconnected(telnet_user_t *user) 166 166 { 167 fibril_mutex_lock(&user-> refcount_mutex);167 fibril_mutex_lock(&user->guard); 168 168 assert(user->locsrv_connection_count > 0); 169 169 user->locsrv_connection_count--; 170 170 fibril_condvar_signal(&user->refcount_cv); 171 fibril_mutex_unlock(&user-> refcount_mutex);171 fibril_mutex_unlock(&user->guard); 172 172 } 173 173 -
uspace/srv/hid/remcons/user.h
r5923cf82 r261bbdc 44 44 /** Representation of a connected (human) user. */ 45 45 typedef struct { 46 /** Mutex guarding the whole structure. */ 47 fibril_mutex_t guard; 48 46 49 /** Internal id, used for creating locfs entries. */ 47 50 int id; … … 65 68 /* Reference counting. */ 66 69 fibril_condvar_t refcount_cv; 67 fibril_mutex_t refcount_mutex;68 70 bool task_finished; 69 71 int locsrv_connection_count;
Note:
See TracChangeset
for help on using the changeset viewer.