Skip to content

Commit

Permalink
GUACAMOLE-1846: Skip user promotion entirely if there are no pending …
Browse files Browse the repository at this point in the history
…users.

(cherry picked from commit 4b32cd8)
  • Loading branch information
jmuehlner committed Sep 12, 2023
1 parent 171219c commit 96a20ac
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/libguac/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,24 +185,22 @@ static void guac_client_promote_pending_users(union sigval data) {
/* Acquire the lock for reading and modifying the list of pending users */
guac_rwlock_acquire_write_lock(&(client->__pending_users_lock));

/* Skip user promotion entirely if there's no pending users */
if (client->__pending_users == NULL)
goto promotion_complete;

/* Run the pending join handler, if one is defined */
if (client->join_pending_handler) {

/* If an error occurs in the pending handler */
if(client->join_pending_handler(client)) {

guac_rwlock_release_lock(&(client->__pending_users_lock));

/* Mark the handler as not running */
pthread_mutex_lock(&(client->__pending_users_timer_mutex));
client->__pending_users_timer_state = GUAC_CLIENT_PENDING_TIMER_REGISTERED;
pthread_mutex_unlock(&(client->__pending_users_timer_mutex));

/* Log a warning and abort the promotion of the pending users */
guac_client_log(client, GUAC_LOG_WARNING,
"join_pending_handler did not successfully complete;"
" any pending users have not been promoted.\n");
return;

goto promotion_complete;
}
}

Expand Down Expand Up @@ -239,6 +237,8 @@ static void guac_client_promote_pending_users(union sigval data) {

guac_rwlock_release_lock(&(client->__users_lock));

promotion_complete:

/* Release the lock (this is done AFTER updating the connected user list
* to ensure that all users are always on exactly one of these lists) */
guac_rwlock_release_lock(&(client->__pending_users_lock));
Expand Down

0 comments on commit 96a20ac

Please sign in to comment.