Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUACAMOLE-1846: Skip user promotion entirely if there are no pending users. #459

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
mike-jumper marked this conversation as resolved.
Show resolved Hide resolved

/* 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