Changeset 5f5d375 in mainline
- Timestamp:
- 2024-10-08T15:12:03Z (3 months ago)
- Branches:
- master
- Children:
- 5e0acaa
- Parents:
- c7ecd290
- git-author:
- Jiri Svoboda <jiri@…> (2024-10-07 18:11:43)
- git-committer:
- Jiri Svoboda <jiri@…> (2024-10-08 15:12:03)
- Location:
- uspace/srv/hid/remcons
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/remcons/remcons.c
rc7ecd290 r5f5d375 540 540 "failed: %s.", APP_GETTERM, user->service_name, APP_SHELL, 541 541 str_error(rc)); 542 fibril_mutex_lock(&user-> guard);542 fibril_mutex_lock(&user->recv_lock); 543 543 user->task_finished = true; 544 544 user->srvs.aborted = true; 545 545 fibril_condvar_signal(&user->refcount_cv); 546 fibril_mutex_unlock(&user-> guard);546 fibril_mutex_unlock(&user->recv_lock); 547 547 return EOK; 548 548 } 549 549 550 fibril_mutex_lock(&user-> guard);550 fibril_mutex_lock(&user->recv_lock); 551 551 user->task_id = task; 552 fibril_mutex_unlock(&user-> guard);552 fibril_mutex_unlock(&user->recv_lock); 553 553 554 554 task_exit_t task_exit; … … 560 560 561 561 /* Announce destruction. */ 562 fibril_mutex_lock(&user-> guard);562 fibril_mutex_lock(&user->recv_lock); 563 563 user->task_finished = true; 564 564 user->srvs.aborted = true; 565 565 fibril_condvar_signal(&user->refcount_cv); 566 fibril_mutex_unlock(&user-> guard);566 fibril_mutex_unlock(&user->recv_lock); 567 567 568 568 return EOK; … … 728 728 729 729 /* Wait for all clients to exit. */ 730 fibril_mutex_lock(&user-> guard);730 fibril_mutex_lock(&user->recv_lock); 731 731 while (!user_can_be_destroyed_no_lock(user)) { 732 732 if (user->task_finished) { … … 740 740 } 741 741 } 742 fibril_condvar_wait_timeout(&user->refcount_cv, &user-> guard, 1000);743 } 744 fibril_mutex_unlock(&user-> guard);742 fibril_condvar_wait_timeout(&user->refcount_cv, &user->recv_lock, 1000); 743 } 744 fibril_mutex_unlock(&user->recv_lock); 745 745 746 746 rc = loc_service_unregister(remcons_srv, user->service_id); -
uspace/srv/hid/remcons/user.c
rc7ecd290 r5f5d375 97 97 98 98 fibril_condvar_initialize(&user->refcount_cv); 99 fibril_mutex_initialize(&user->guard); 99 fibril_mutex_initialize(&user->send_lock); 100 fibril_mutex_initialize(&user->recv_lock); 100 101 user->task_finished = false; 101 102 user->socket_closed = false; … … 151 152 152 153 telnet_user_t *tmp = user; 153 fibril_mutex_lock(&tmp-> guard);154 fibril_mutex_lock(&tmp->recv_lock); 154 155 user->locsrv_connection_count++; 155 156 … … 163 164 } 164 165 165 fibril_mutex_unlock(&tmp-> guard);166 fibril_mutex_unlock(&tmp->recv_lock); 166 167 167 168 fibril_mutex_unlock(&users_guard); … … 176 177 void telnet_user_notify_client_disconnected(telnet_user_t *user) 177 178 { 178 fibril_mutex_lock(&user-> guard);179 fibril_mutex_lock(&user->recv_lock); 179 180 assert(user->locsrv_connection_count > 0); 180 181 user->locsrv_connection_count--; 181 182 fibril_condvar_signal(&user->refcount_cv); 182 fibril_mutex_unlock(&user-> guard);183 fibril_mutex_unlock(&user->recv_lock); 183 184 } 184 185 … … 189 190 bool telnet_user_is_zombie(telnet_user_t *user) 190 191 { 191 fibril_mutex_lock(&user-> guard);192 fibril_mutex_lock(&user->recv_lock); 192 193 bool zombie = user->socket_closed || user->task_finished; 193 fibril_mutex_unlock(&user-> guard);194 fibril_mutex_unlock(&user->recv_lock); 194 195 195 196 return zombie; … … 401 402 { 402 403 uint8_t *bp = (uint8_t *)buf; 403 fibril_mutex_lock(&user-> guard);404 fibril_mutex_lock(&user->recv_lock); 404 405 405 406 assert(size > 0); … … 417 418 &next_byte); 418 419 if (rc != EOK) { 419 fibril_mutex_unlock(&user-> guard);420 fibril_mutex_unlock(&user->recv_lock); 420 421 return rc; 421 422 } … … 453 454 } while (size > 0 && (telnet_user_byte_avail(user) || *nread == 0)); 454 455 455 fibril_mutex_unlock(&user-> guard);456 fibril_mutex_unlock(&user->recv_lock); 456 457 return EOK; 457 458 } … … 534 535 size_t size) 535 536 { 536 fibril_mutex_lock(&user-> guard);537 fibril_mutex_lock(&user->send_lock); 537 538 538 539 errno_t rc = telnet_user_send_data_locked(user, data, size); 539 540 540 fibril_mutex_unlock(&user-> guard);541 fibril_mutex_unlock(&user->send_lock); 541 542 542 543 return rc; … … 552 553 size_t size) 553 554 { 554 fibril_mutex_lock(&user-> guard);555 fibril_mutex_lock(&user->send_lock); 555 556 556 557 errno_t rc = telnet_user_send_raw_locked(user, data, size); 557 558 558 fibril_mutex_unlock(&user-> guard);559 fibril_mutex_unlock(&user->send_lock); 559 560 560 561 return rc; … … 577 578 errno_t rc; 578 579 579 fibril_mutex_lock(&user-> guard);580 fibril_mutex_lock(&user->send_lock); 580 581 rc = telnet_user_flush_locked(user); 581 fibril_mutex_unlock(&user-> guard);582 fibril_mutex_unlock(&user->send_lock); 582 583 return rc; 583 584 } … … 592 593 void telnet_user_update_cursor_x(telnet_user_t *user, int new_x) 593 594 { 594 fibril_mutex_lock(&user-> guard);595 fibril_mutex_lock(&user->send_lock); 595 596 if (user->cursor_x - 1 == new_x) { 596 597 char data = '\b'; … … 599 600 } 600 601 user->cursor_x = new_x; 601 fibril_mutex_unlock(&user-> guard);602 fibril_mutex_unlock(&user->send_lock); 602 603 603 604 } -
uspace/srv/hid/remcons/user.h
rc7ecd290 r5f5d375 52 52 /** Representation of a connected (human) user. */ 53 53 typedef struct { 54 /** Mutex guarding the whole structure. */ 55 fibril_mutex_t guard; 54 /** Synchronize send operations */ 55 fibril_mutex_t send_lock; 56 /** Synchronize receive operations */ 57 fibril_mutex_t recv_lock; 56 58 /** Callback functions */ 57 59 telnet_cb_t *cb;
Note:
See TracChangeset
for help on using the changeset viewer.