extern pthread_key_t MyConKey;
-
+char *server_cookie = NULL;
char *defaulthost = DEFAULT_HOST;
char tracefile[PATH_MAX];
/* Parse command line */
- while ((a = getopt(argc, argv, "hp:t:")) != EOF)
+ while ((a = getopt(argc, argv, "hp:t:c")) != EOF)
switch (a) {
case 'p':
port = atoi(optarg);
freopen(tracefile, "w", stderr);
freopen(tracefile, "r", stdin);
break;
+ case 'c':
+ server_cookie = malloc(SIZ);
+ if (server_cookie != NULL) {
+ strcpy(server_cookie, "Set-cookie: wcserver=");
+ if (gethostname(
+ &server_cookie[strlen(server_cookie)],
+ 200) != 0) {
+ fprintf(stderr, "gethostname: %s\n",
+ strerror(errno));
+ free(server_cookie);
+ }
+ }
+ break;
default:
fprintf(stderr, "usage: webserver [-p localport] "
- "[-t tracefile] "
+ "[-t tracefile] [-c] "
"[remotehost [remoteport]]\n");
return 1;
}
}
/* Tell 'em who's in da house */
fprintf(stderr, SERVER "\n"
- "Copyright (C) 1996-2000\n"
+ "Copyright (C) 1996-2001\n"
"This software is distributed under the terms of the GNU\n"
"General Public License. All other rights reserved.\n\n");
/* Start a few initial worker threads */
- for (i=0; i<(INITIAL_WORKER_THREADS-1); ++i) {
+ for (i=0; i<(INITIAL_WORKER_THREADS); ++i) {
spawn_another_worker_thread();
}
- /* now the original thread becomes an ordinary worker thread */
- worker_entry();
+ /* now the original thread can go away. */
+ pthread_exit(NULL);
return 0;
}