Mon, 27 May 2013 12:28:56 +0200
some fixes for mod_jk
--- a/src/server/daemon/main.c Sun May 26 22:05:41 2013 +0200 +++ b/src/server/daemon/main.c Mon May 27 12:28:56 2013 +0200 @@ -71,6 +71,7 @@ * SIGTERM: stop the server */ void sig_term(int sig) { + webserver_shutdown(); exit(EXIT_SUCCESS); } @@ -91,7 +92,7 @@ int main(int argc, char **argv) { //test(); - + /* if the -c parameter is specified, we don't create a daemon */ int d = 1; for(int i=0;i<argc;i++) { @@ -141,6 +142,7 @@ /* add signal handler */ signal(SIGUSR1, sig_usr1_reload); signal(SIGTERM, sig_term); + signal(SIGINT, sig_term); /* start webserver */ int status;
--- a/src/server/daemon/webserver.c Sun May 26 22:05:41 2013 +0200 +++ b/src/server/daemon/webserver.c Mon May 27 12:28:56 2013 +0200 @@ -54,6 +54,7 @@ extern struct FuncStruct webserver_funcs[]; +static RestartCallback *atrestart; int webserver_init() { // init NSPR @@ -158,11 +159,37 @@ return 0; } +void webserver_shutdown() { + printf("webserver_shutdown\n"); + + // execute restart callbacks + RestartCallback *re = atrestart; + while(re) { + re->func(re->data); + re = re->next; + } +} void webserver_atrestart(void (*fn)(void *), void *data) { - /* - * TODO: implement later - * only for mod_jk at this time - */ + RestartCallback *cb = malloc(sizeof(RestartCallback)); + cb->func = fn; + cb->data = data; + cb->next = NULL; + + if(atrestart) { + RestartCallback *elm = atrestart; + while(elm) { + if(!elm->next) { + elm->next = cb; + break; + } + elm = elm->next; + } + } else { + atrestart = cb; + } } +int nsapi_runtime_version() { + return 303; +}
--- a/src/server/daemon/webserver.h Sun May 26 22:05:41 2013 +0200 +++ b/src/server/daemon/webserver.h Mon May 27 12:28:56 2013 +0200 @@ -34,10 +34,17 @@ #ifdef __cplusplus extern "C" { #endif + +typedef struct restart_callback RestartCallback; +struct restart_callback { + void (*func)(void *); + void *data; + RestartCallback *next; +}; int webserver_init(); int webserver_run(); - +void webserver_shutdown(); void webserver_atrestart(void (*fn)(void *), void *data);
--- a/src/server/public/nsapi.h Sun May 26 22:05:41 2013 +0200 +++ b/src/server/public/nsapi.h Mon May 27 12:28:56 2013 +0200 @@ -1109,20 +1109,28 @@ * In Sun ONE Web Server 6.1 and higher, http_parse_request("", NULL, NULL) * returns the NSAPI version. In previous releases, it returns -1. */ -#define __NSAPI_RUNTIME_VERSION \ - ((*__nsapi30_table->f_http_parse_request)("", NULL, NULL)) +//define __NSAPI_RUNTIME_VERSION \ +// ((*__nsapi30_table->f_http_parse_request)("", NULL, NULL)) + +// new: +#define __NSAPI_RUNTIME_VERSION nsapi_runtime_version() /* * NSAPI_RUNTIME_VERSION returns the NSAPI version the server implements. The * returned NSAPI version number is reliable only in iPlanet Web Server 6.0, * Netscape Enterprise Server 6.0, and Sun ONE Web Server 6.0 and higher. */ -#define NSAPI_RUNTIME_VERSION \ - (__NSAPI_RUNTIME_VERSION > 0 ? __NSAPI_RUNTIME_VERSION : 301) +//define NSAPI_RUNTIME_VERSION \ +// (__NSAPI_RUNTIME_VERSION > 0 ? __NSAPI_RUNTIME_VERSION : 301) + +// new: +#define NSAPI_RUNTIME_VERSION nsapi_runtime_version() #endif /* NSAPI_VERSION >= 301 */ -#define system_version (*__nsapi30_table->f_system_version) +//define system_version (*__nsapi30_table->f_system_version) +// new: +NSAPI_PUBLIC char* system_version(); /* * Depending on the system, memory allocated via these macros may come from
--- a/src/server/util/system.c Sun May 26 22:05:41 2013 +0200 +++ b/src/server/util/system.c Mon May 27 12:28:56 2013 +0200 @@ -92,7 +92,7 @@ NSAPI_PUBLIC char *system_version() { //return PRODUCT_ID"/"PRODUCT_VERSION_ID; - return "Solaris 11"; + return "webserver/alpha"; } NSAPI_PUBLIC pool_handle_t *system_pool(void)