int home_specified = 0; /* did the user specify a homedir? */
int time_to_die = 0; /* Nonzero if server is shutting down */
int DisableGzip = 0;
-extern void *context_loop(int*);
+extern void *context_loop(ParsedHttpHdrs *Hdr);
extern void *housekeeping_loop(void);
extern pthread_mutex_t SessionListMutex;
extern pthread_key_t MyConKey;
*/
pid_t current_child;
void graceful_shutdown(int signum) {
- char wd[SIZ];
FILE *FD;
int fd;
- getcwd(wd, SIZ);
- lprintf (1, "bye going down gracefull.[%d][%s]\n", signum, wd);
+
+ lprintf (1, "WebCit is being shut down on signal %d.\n", signum);
fd = msock;
msock = -1;
time_to_die = 1;
pid_t child = 0;
FILE *fp;
int do_restart = 0;
+ int rv;
+ FILE *rvfp = NULL;
current_child = 0;
* We don't just call close() because we don't want these fd's
* to be reused for other files.
*/
- chdir("/");
+ rv = chdir("/");
signal(SIGHUP, SIG_IGN);
signal(SIGINT, SIG_IGN);
setsid();
umask(0);
- freopen("/dev/null", "r", stdin);
- freopen("/dev/null", "w", stdout);
- freopen("/dev/null", "w", stderr);
+ rvfp = freopen("/dev/null", "r", stdin);
+ rvfp = freopen("/dev/null", "w", stdout);
+ rvfp = freopen("/dev/null", "w", stderr);
signal(SIGTERM, graceful_shutdown_watcher);
signal(SIGHUP, graceful_shutdown_watcher);
pthread_attr_t attr; /* Thread attributes */
int ret;
- lprintf(3, "Creating a new thread\n");
+ lprintf(3, "Creating a new thread. Pool size is now %d\n", ++num_threads);
/* set attributes for the new thread */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
/*
- * Our per-thread stacks need to be bigger than the default size, otherwise
- * the MIME parser crashes on FreeBSD, and the IMAP service crashes on
- * 64-bit Linux.
+ * Our per-thread stacks need to be bigger than the default size,
+ * otherwise the MIME parser crashes on FreeBSD.
*/
if ((ret = pthread_attr_setstacksize(&attr, 1024 * 1024))) {
lprintf(1, "pthread_attr_setstacksize: %s\n",
char webcitdir[PATH_MAX] = DATADIR;
char *pidfile = NULL;
char *hdir;
- const char *basedir;
-#ifdef ENABLE_NLS
- char *locale = NULL;
- char *mo = NULL;
-#endif /* ENABLE_NLS */
+ const char *basedir = NULL;
char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */
const char *I18nDumpFile = NULL;
+ FILE *rvfp = NULL;
WildFireInitBacktrace(argv[0], 2);
/* Parse command line */
#ifdef HAVE_OPENSSL
- while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfsZ")) != EOF)
+ while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfsS:Z")) != EOF)
#else
while ((a = getopt(argc, argv, "h:i:p:t:T:B:x:dD:G:cfZ")) != EOF)
#endif
case 'h':
hdir = strdup(optarg);
relh=hdir[0]!='/';
- if (!relh) safestrncpy(webcitdir, hdir,
- sizeof webcitdir);
- else
- safestrncpy(relhome, relhome,
- sizeof relhome);
+ if (!relh) {
+ safestrncpy(webcitdir, hdir, sizeof webcitdir);
+ }
+ else {
+ safestrncpy(relhome, relhome, sizeof relhome);
+ }
/* free(hdir); TODO: SHOULD WE DO THIS? */
home_specified = 1;
home=1;
break;
case 't':
safestrncpy(tracefile, optarg, sizeof tracefile);
- freopen(tracefile, "w", stdout);
- freopen(tracefile, "w", stderr);
- freopen(tracefile, "r", stdin);
+ rvfp = freopen(tracefile, "w", stdout);
+ rvfp = freopen(tracefile, "w", stderr);
+ rvfp = freopen(tracefile, "r", stdin);
break;
case 'T':
LoadTemplates = atoi(optarg);
}
}
break;
+#ifdef HAVE_OPENSSL
case 's':
is_https = 1;
break;
+ case 'S':
+ is_https = 1;
+ ssl_cipher_list = strdup(optarg);
+ break;
+#endif
case 'G':
DumpTemplateI18NStrings = 1;
I18nDump = NewStrBufPlain(HKEY("int templatestrings(void)\n{\n"));
"[-T Templatedebuglevel] "
"[-d] [-Z] [-G i18ndumpfile] "
#ifdef HAVE_OPENSSL
- "[-s] "
+ "[-s] [-S cipher_suites]"
#endif
"[remotehost [remoteport]]\n");
return 1;
/* initialize the International Bright Young Thing */
-#ifdef ENABLE_NLS
- initialize_locales();
-
-
- locale = setlocale(LC_ALL, "");
-
- mo = malloc(strlen(webcitdir) + 20);
- lprintf(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale"));
- free(mo);
- lprintf(9, "Text domain: %s\n", textdomain("webcit"));
- lprintf(9, "Text domain Charset: %s\n", bind_textdomain_codeset("webcit","UTF8"));
-#endif
initialise_modules();
initialize_viewdefs();
icalmemory_free_ring ();
ShutDownLibCitadel ();
shutdown_modules ();
-#ifdef ENABLE_NLS
- ShutdownLocale();
-#endif
#ifdef HAVE_OPENSSL
if (is_https) {
shutdown_ssl();
int ret;
struct timeval tv;
fd_set readset, tempset;
+ ParsedHttpHdrs Hdr;
+ memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
+ Hdr.HR.eReqType = eGET;
+ http_new_modules(&Hdr);
tv.tv_sec = 0;
tv.tv_usec = 10000;
FD_ZERO(&readset);
end_critical_section(S_SHUTDOWN);
if (shutdown == 1)
{/* we're the one to cleanup the mess. */
+ http_destroy_modules(&Hdr);
lprintf(2, "I'm master shutdown: tagging sessions to be killed.\n");
shutdown_sessions();
lprintf(2, "master shutdown: waiting for others\n");
#endif
if (fail_this_transaction == 0) {
- ParsedHttpHdrs Hdr;
- memset(&Hdr, 0, sizeof(ParsedHttpHdrs));
- Hdr.HR.eReqType = eGET;
Hdr.http_sock = ssock;
/* Perform an HTTP transaction... */
/* ...and close the socket. */
if (Hdr.http_sock > 0)
lingering_close(ssock);
+ http_detach_modules(&Hdr);
+
}
}
} while (!time_to_die);
+ http_destroy_modules(&Hdr);
lprintf (1, "bye\n");
pthread_exit(NULL);
}