$Log$
+Revision 1.445 2000/01/17 05:38:14 ajc
+* citserver.c: cleanup hook functions are now run under the proper context,
+ even when initiated by the housekeeper thread
+* serv_pop3.c: establish a place to hold the message list
+
Revision 1.444 2000/01/17 04:26:39 ajc
* Modified CtdlOutputMsg() to handle output to arbitrary sockets or files.
This uses nested functions and may not be portable beyond GCC...
Fri Jul 10 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
* Initial CVS import
+
return;
}
+ /* Run any cleanup routines registered by loadable modules.
+ * Note 1: This must occur *before* deallocate_user_data() because the
+ * cleanup functions might touch dynamic session data.
+ * Note 2: We have to "become_session()" because the cleanup functions
+ * might make references to "CC" assuming it's the right one.
+ */
+ become_session(con);
+ PerformSessionHooks(EVT_STOP);
+ become_session(NULL);
+
/* Now handle all of the administrivia. */
lprintf(7, "Calling logout(%d)\n", con->cs_pid);
logout(con);
unlink(con->temp);
lprintf(3, "citserver[%3d]: ended.\n", con->cs_pid);
- /* Run any cleanup routines registered by loadable modules.
- * (Must occur *before* deallocate_user_data() because the cleanup
- * functions might touch dynamic session data)
- */
- PerformSessionHooks(EVT_STOP);
syslog(LOG_NOTICE,"session %d ended", con->cs_pid);
#include "msgbase.h"
#include "tools.h"
#include "internet_addressing.h"
+#include "serv_pop3.h"
-struct pop3msg {
- long msgnum;
- size_t rfc822_length;
- int deleted;
- FILE *temp;
-};
-
-struct citpop3 { /* Information about the current session */
- struct pop3msg *msgs;
- int num_msgs;
-};
-
-#define POP3 ((struct citpop3 *)CtdlGetUserData(SYM_POP3))
-
long SYM_POP3;
void pop3_cleanup_function(void) {
int i;
+ /* Don't do this stuff if this is not a POP3 session! */
+ if (CC->h_command_function != pop3_command_loop) return;
+
lprintf(9, "Performing POP3 cleanup hook\n");
if (POP3->num_msgs > 0) for (i=0; i<POP3->num_msgs; ++i) {
fclose(POP3->msgs[i].temp);
}
if (POP3->msgs != NULL) phree(POP3->msgs);
+
+ lprintf(9, "Finished POP3 cleanup hook\n");
}
--- /dev/null
+
+struct pop3msg {
+ long msgnum;
+ size_t rfc822_length;
+ int deleted;
+ FILE *temp;
+};
+
+struct citpop3 { /* Information about the current session */
+ struct pop3msg *msgs;
+ int num_msgs;
+};
+
+#define POP3 ((struct citpop3 *)CtdlGetUserData(SYM_POP3))
+
+void pop3_cleanup_function(void);
+void pop3_greeting(void);
+void pop3_user(char *argbuf);
+void pop3_pass(char *argbuf);
+void pop3_list(char *argbuf);
+void pop3_command_loop(void);
}
-
-
+/*
+ * Bind a thread to a context.
+ */
+inline void become_session(struct CitContext *which_con) {
+ pthread_setspecific(MyConKey, (void *)which_con );
+}
SO_REUSEADDR,
&i, sizeof(i));
- pthread_setspecific(MyConKey,
- (void *)con);
+ become_session(con);
begin_session(con);
serviceptr->h_greeting_function();
- pthread_setspecific(MyConKey,
- (void *)NULL);
+ become_session(NULL);
con->state = CON_IDLE;
goto SETUP_FD;
}
/* We're bound to a session, now do *one* command */
if (bind_me != NULL) {
- pthread_setspecific(MyConKey, (void *)bind_me);
+ become_session(bind_me);
CC->h_command_function();
- pthread_setspecific(MyConKey, (void *)NULL);
+ become_session(NULL);
bind_me->state = CON_IDLE;
if (bind_me->kill_me == 1) {
RemoveContext(bind_me);
void cmd_nset (char *cmdbuf);
int convert_login (char *NameToConvert);
void worker_thread (void);
+inline void become_session(struct CitContext *which_con);
extern int num_sessions;