From: Art Cancro Date: Wed, 19 Mar 2008 19:28:48 +0000 (+0000) Subject: EVT_LOGOUT hooks are now called with the thread's current X-Git-Tag: v7.86~2401 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=82cc269aac09100aec87a0d19635e943ce1efbc8 EVT_LOGOUT hooks are now called with the thread's current CitContext set to that of the session being logged out, even when killing a session administratively. This allows the identity of the user to be passed along to module hooks. This fixes the problem in the Jabber server where buddy 'ghosts' whould remain visible to clients if the user disconnected without logging off. --- diff --git a/citadel/citadel_ipc.c b/citadel/citadel_ipc.c index a402ec129..9e0c43377 100644 --- a/citadel/citadel_ipc.c +++ b/citadel/citadel_ipc.c @@ -142,7 +142,7 @@ int CtdlIPCQuit(CtdlIPC *ipc) /* - * Asks the server to logout. Should always return 200, even if no user + * Asks the server to log out. Should always return 200, even if no user * was logged in. The user will not be logged in after this! */ int CtdlIPCLogout(CtdlIPC *ipc) diff --git a/citadel/citserver.c b/citadel/citserver.c index 6dba61993..2ec710809 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -248,13 +248,10 @@ void RemoveContext (struct CitContext *con) * might make references to "CC" assuming it's the right one. */ become_session(con); + logout(); PerformSessionHooks(EVT_STOP); become_session(NULL); - /* Now handle all of the administrivia. */ - lprintf(CTDL_DEBUG, "Calling logout(%d)\n", con->cs_pid); - logout(con); - lprintf(CTDL_NOTICE, "[%3d] Session ended.\n", con->cs_pid); /* If the client is still connected, blow 'em away. */ @@ -1085,7 +1082,7 @@ void do_command_loop(void) { } else if (!strncasecmp(cmdbuf,"LOUT",4)) { - if (CC->logged_in) logout(CC); + if (CC->logged_in) logout(); cprintf("%d logged out.\n", CIT_OK); } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 8b2b9d19a..b638ccc20 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -619,50 +619,51 @@ void logged_in_response(void) /* * misc things to be taken care of when a user is logged out */ -void logout(struct CitContext *who) +void logout(void) { - /* - * Clear out some session data. Most likely, the CitContext for this - * session is about to get nuked when the session disconnects, but - * since it's possible to log in again without reconnecting, we cannot - * make that assumption. - */ - strcpy(who->fake_username, ""); - strcpy(who->fake_hostname, ""); - strcpy(who->fake_roomname, ""); - who->logged_in = 0; - + struct CitContext *CCC = CC; /* CachedCitContext - performance boost */ /* * If there is a download in progress, abort it. */ - if (who->download_fp != NULL) { - fclose(who->download_fp); - who->download_fp = NULL; + if (CCC->download_fp != NULL) { + fclose(CCC->download_fp); + CCC->download_fp = NULL; } /* * If there is an upload in progress, abort it. */ - if (who->upload_fp != NULL) { - abort_upl(who); + if (CCC->upload_fp != NULL) { + abort_upl(CCC); } /* * If we were talking to a network node, we're not anymore... */ - if (!IsEmptyStr(who->net_node)) { - network_talking_to(who->net_node, NTT_REMOVE); + if (!IsEmptyStr(CCC->net_node)) { + network_talking_to(CCC->net_node, NTT_REMOVE); } - /* Do modular stuff... */ + /* Run any hooks registered by modules... */ PerformSessionHooks(EVT_LOGOUT); + /* + * Clear out some session data. Most likely, the CitContext for this + * session is about to get nuked when the session disconnects, but + * since it's possible to log in again without reconnecting, we cannot + * make that assumption. + */ + strcpy(CCC->fake_username, ""); + strcpy(CCC->fake_hostname, ""); + strcpy(CCC->fake_roomname, ""); + CCC->logged_in = 0; + /* Check to see if the user was deleted whilst logged in and purge them if necessary */ - if (who->user.axlevel == 0) - purge_user(who->user.fullname); + if (CCC->user.axlevel == 0) + purge_user(CCC->user.fullname); /* Free any output buffers */ - if (who->output_buffer != NULL) { + if (CCC->output_buffer != NULL) { unbuffer_output(); } } diff --git a/citadel/user_ops.h b/citadel/user_ops.h index be1d4716d..9aad99642 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -9,7 +9,7 @@ int is_room_aide (void); int getuserbynumber (struct ctdluser *usbuf, long int number); void cmd_user (char *cmdbuf); void session_startup (void); -void logout (struct CitContext *who); +void logout (void); void cmd_pass (char *buf); int purge_user (char *pname); int create_user (char *newusername, int become_user);