$Log$
+ Revision 641.26 2005/03/12 05:42:35 ajc
+ * Trying to fix a memory bug somewhere.
+ * While working on the above, noticed that the way we did the per-session
+ dynamic symbols loses badly in terms of performance. Began moving to
+ a less modular but better performing way of doing the same.
+
Revision 641.25 2005/03/10 03:36:25 ajc
* Silenced a compiler warning
* Our graceful cleanup handler no longer gracefully cleans up after
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
+
+
#ifndef CITADEL_H
#define CITADEL_H
+/* #include <dmalloc.h> uncomment if using dmalloc */
/* Build Citadel with the calendar service only if the header *and*
* library for libical are both present.
IMAP->cached_bodymsgnum = (-1);
}
+ free(IMAP);
lprintf(CTDL_DEBUG, "Finished IMAP cleanup hook\n");
}
{
strcpy(CC->cs_clientname, "IMAP session");
- CtdlAllocUserData(SYM_IMAP, sizeof(struct citimap));
+ IMAP = malloc(sizeof (struct citimap));
IMAP->authstate = imap_as_normal;
IMAP->cached_rfc822_data = NULL;
IMAP->cached_rfc822_msgnum = (-1);
#define IMAP_RECENT 64 /* reportable but not setable */
-#define IMAP ((struct citimap *)CtdlGetUserData(SYM_IMAP))
+#define IMAP CC->IMAP
/*
* When loading arrays of message ID's into memory, increase the buffer to
lprintf(CTDL_DEBUG, "Performing POP3 cleanup hook\n");
if (POP3->msgs != NULL) free(POP3->msgs);
+
+ free(POP3);
}
void pop3_greeting(void) {
strcpy(CC->cs_clientname, "POP3 session");
CC->internal_pgm = 1;
- CtdlAllocUserData(SYM_POP3, sizeof(struct citpop3));
+ POP3 = malloc(sizeof(struct citpop3));
POP3->msgs = NULL;
POP3->num_msgs = 0;
* incremented by one.
*/
-#define POP3 ((struct citpop3 *)CtdlGetUserData(SYM_POP3))
+#define POP3 CC->POP3
void pop3_cleanup_function(void);
void pop3_greeting(void);
smtp_deliver_remote
};
-#define SMTP ((struct citsmtp *)CtdlGetUserData(SYM_SMTP))
-#define SMTP_RECPS ((char *)CtdlGetUserData(SYM_SMTP_RECPS))
-#define SMTP_ROOMS ((char *)CtdlGetUserData(SYM_SMTP_ROOMS))
+#define SMTP CC->SMTP
+#define SMTP_RECPS CC->SMTP_RECPS
+#define SMTP_ROOMS CC->SMTP_ROOMS
int run_queue_now = 0; /* Set to 1 to ignore SMTP send retry times */
/*****************************************************************************/
-
-
/*
* Here's where our SMTP session begins its happy day.
*/
strcpy(CC->cs_clientname, "SMTP session");
CC->internal_pgm = 1;
CC->cs_flags |= CS_STEALTH;
- CtdlAllocUserData(SYM_SMTP, sizeof(struct citsmtp));
- CtdlAllocUserData(SYM_SMTP_RECPS, SIZ);
- CtdlAllocUserData(SYM_SMTP_ROOMS, SIZ);
+ SMTP = malloc(sizeof(struct citsmtp));
+ SMTP_RECPS = malloc(SIZ);
+ SMTP_ROOMS = malloc(SIZ);
snprintf(SMTP_RECPS, SIZ, "%s", "");
snprintf(SMTP_ROOMS, SIZ, "%s", "");
/*****************************************************************************/
/* MODULE INITIALIZATION STUFF */
/*****************************************************************************/
+/*
+ * This cleanup function blows away the temporary memory used by
+ * the SMTP server.
+ */
+void smtp_cleanup_function(void) {
+
+ /* Don't do this stuff if this is not an SMTP session! */
+ if (CC->h_command_function != smtp_command_loop) return;
+
+ lprintf(CTDL_DEBUG, "Performing SMTP cleanup hook\n");
+ free(SMTP);
+ free(SMTP_ROOMS);
+ free(SMTP_RECPS);
+}
+
+
+
char *serv_smtp_init(void)
smtp_init_spoolout();
CtdlRegisterSessionHook(smtp_do_queue, EVT_TIMER);
+ CtdlRegisterSessionHook(smtp_cleanup_function, EVT_STOP);
CtdlRegisterProtoHook(cmd_smtp, "SMTP", "SMTP utility commands");
return "$Id$";
}
SYM_DESIRED_SECTION, /* Used by the MIME parser */
SYM_MA_INFO, /* Handles multipart/alternative */
SYM_CIT_ICAL, /* Used by the calendar service */
- SYM_IMAP, /* Used by the IMAP service */
- SYM_POP3, /* Used by the POP3 service */
- SYM_SMTP, /* Used by the SMTP service */
- SYM_SMTP_RECPS,
- SYM_SMTP_ROOMS,
SYM_VCARD, /* vCard handling requires this */
SYM_MAX
};
/* Dynamically allocated session data */
struct CtdlSessData *FirstSessData;
+ struct citimap *IMAP;
+ struct citpop3 *POP3;
+ struct citsmtp *SMTP;
+ char *SMTP_RECPS;
+ char *SMTP_ROOMS;
};
typedef struct CitContext t_context;
"*** Citadel server engine v%d.%02d ***\n",
(REV_LEVEL/100), (REV_LEVEL%100));
lprintf(CTDL_NOTICE,
- "Copyright (C) 1987-2004 by the Citadel development team.\n");
+ "Copyright (C) 1987-2005 by the Citadel development team.\n");
lprintf(CTDL_NOTICE,
"This program is distributed under the terms of the GNU "
"General Public License.\n");
if (i == 0) sleep(3);
}
- fprintf(stderr, "Starting in %d seconds\r", n);
- sleep(n);
+ //fprintf(stderr, "Starting in %d seconds\r", n);
+ //sleep(n);
fprintf(stderr, " \r");
/* Then, signal the conditional they all are waiting on */