GUACAMOLE-33: Restore guac_common_cursor_remove_user() (reverts commit af7968e).

This commit is contained in:
Michael Jumper 2016-04-18 18:53:12 -07:00
parent 7e3c28a1c2
commit 92e2f4e420
4 changed files with 38 additions and 0 deletions

View File

@ -367,3 +367,12 @@ void guac_common_cursor_set_blank(guac_common_cursor* cursor) {
} }
void guac_common_cursor_remove_user(guac_common_cursor* cursor,
guac_user* user) {
/* Disassociate from given user */
if (cursor->user == user)
cursor->user = NULL;
}

View File

@ -249,4 +249,19 @@ void guac_common_cursor_set_ibar(guac_common_cursor* cursor);
*/ */
void guac_common_cursor_set_blank(guac_common_cursor* cursor); void guac_common_cursor_set_blank(guac_common_cursor* cursor);
/**
* Removes the given user, such that future synchronization will not occur.
* This is necessary when a user leaves the connection. If a user leaves the
* connection and this is not called, the corresponding guac_user and socket
* may cease to be valid, and future synchronization attempts will segfault.
*
* @param cursor
* The cursor to remove the user from.
*
* @param user
* The user to remove.
*/
void guac_common_cursor_remove_user(guac_common_cursor* cursor,
guac_user* user);
#endif #endif

View File

@ -97,3 +97,12 @@ int guac_vnc_user_join_handler(guac_user* user, int argc, char** argv) {
} }
int guac_vnc_user_leave_handler(guac_user* user) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
guac_common_cursor_remove_user(vnc_client->display->cursor, user);
return 0;
}

View File

@ -29,5 +29,10 @@
*/ */
guac_user_join_handler guac_vnc_user_join_handler; guac_user_join_handler guac_vnc_user_join_handler;
/**
* Handler for leaving users.
*/
guac_user_leave_handler guac_vnc_user_leave_handler;
#endif #endif