X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=server%2Fstatserv.c;h=2e01fbb31fc197c28fc4ad250c19b5e67e3742a7;hp=c69444301038700e25a0fedd2ada1f7a5fd31d7a;hb=db585d7fcb8319fa86543eb062df7fdaf16858c6;hpb=e26ffdbc4b024a06b4ca46c6aecb5c3dd09b7e8d diff --git a/server/statserv.c b/server/statserv.c index c694443..2e01fbb 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -1,12 +1,12 @@ /* - * Copyright (c) 1995-2002, Index Data + * Copyright (c) 1995-2003, Index Data * See the file LICENSE for details. * Sebastian Hammer, Adam Dickmeiss * * NT threaded server code by * Chas Woodfield, Fretwell Downing Informatics. * - * $Id: statserv.c,v 1.87 2002-11-26 16:04:15 adam Exp $ + * $Id: statserv.c,v 1.93 2003-02-17 21:23:31 adam Exp $ */ #include @@ -58,7 +58,7 @@ statserv_options_block control_block = { "", /* diagnostic output to stderr */ "tcp:@:9999", /* default listener port */ PROTO_Z3950, /* default application protocol */ - 60, /* idle timeout (minutes) */ + 15, /* idle timeout (minutes) */ 1024*1024, /* maximum PDU size (approx.) to allow */ "default-config", /* configuration name to pass to backend */ "", /* set user id */ @@ -70,13 +70,14 @@ statserv_options_block control_block = { 0, /* default value for inet deamon */ 0, /* handle (for service, etc) */ 0, /* bend_init handle */ - 0 /* bend_close handle */ + 0, /* bend_close handle */ #ifdef WIN32 - ,"Z39.50 Server", /* NT Service Name */ + "Z39.50 Server", /* NT Service Name */ "Server", /* NT application Name */ "", /* NT Service Dependencies */ - "Z39.50 Server" /* NT Service Display Name */ + "Z39.50 Server", /* NT Service Display Name */ #endif /* WIN32 */ + 0 /* SOAP handlers */ }; /* @@ -304,7 +305,7 @@ static void listener(IOCHAN h, int event) yaz_log(LOG_DEBUG, "Setting timeout %d", control_block.idle_timeout); iochan_setdata(new_chan, newas); - iochan_settimeout(new_chan, control_block.idle_timeout * 60); + iochan_settimeout(new_chan, 60); /* Now what we need todo is create a new thread with this iochan as the parameter */ @@ -354,7 +355,6 @@ void statserv_closedown() { IOCHAN p; -/* CHANGE */ if (control_block.bend_stop) (*control_block.bend_stop)(&control_block); for (p = pListener; p; p = p->next) @@ -416,6 +416,10 @@ static void listener(IOCHAN h, int event) } sprintf(nbuf, "%s(%d)", me, getpid()); yaz_log_init(control_block.loglevel, nbuf, 0); + /* ensure that bend_stop is not called when each child exits - + only for the main process .. + */ + control_block.bend_stop = 0; } else /* parent */ { @@ -443,7 +447,7 @@ static void listener(IOCHAN h, int event) if ((res = cs_listen_check(line, 0, 0, control_block.check_ip, control_block.daemon_name)) < 0) { - yaz_log(LOG_WARN, "cs_listen failed"); + yaz_log(LOG_WARN|LOG_ERRNO, "cs_listen failed"); return; } else if (res == 1) @@ -561,7 +565,7 @@ static void *new_session (void *vp) newas->cs_get_mask = cs_get_mask; iochan_setdata(new_chan, newas); - iochan_settimeout(new_chan, control_block.idle_timeout * 60); + iochan_settimeout(new_chan, 60); a = cs_addrstr(new_line); yaz_log(LOG_LOG, "Starting session %d from %s", no_sessions, a ? a : "[Unknown]"); @@ -688,6 +692,33 @@ void statserv_setcontrol(statserv_options_block *block) memcpy(&control_block, block, sizeof(*block)); } +void statserv_add_soap_handler(int (*h)(struct bend_soap_rr *rr), + const char *ns) +{ + struct bend_soap_handler *sh = (struct bend_soap_handler *) + xmalloc(sizeof(*sh)); + + sh->handler = h; + sh->ns = xstrdup(ns); + sh->next = control_block.soap_handlers; + control_block.soap_handlers = sh; + yaz_log(LOG_LOG, "soap handler added"); +} + +static void statserv_reset(void) +{ + struct bend_soap_handler *sh = control_block.soap_handlers; + + control_block.soap_handlers = 0; + while (sh) + { + struct bend_soap_handler *sh_next = sh->next; + xfree (sh->ns); + xfree (sh); + sh = sh_next; + } +} + int statserv_start(int argc, char **argv) { int ret; @@ -712,14 +743,14 @@ int statserv_start(int argc, char **argv) if (control_block.bend_start) (*control_block.bend_start)(&control_block); #ifdef WIN32 - logf (LOG_LOG, "Starting server %s", me); + yaz_log (LOG_LOG, "Starting server %s", me); #else /* UNIX */ if (control_block.inetd) inetd_connection(control_block.default_proto); else { - logf (LOG_LOG, "Starting server %s pid=%d", me, getpid()); + yaz_log (LOG_LOG, "Starting server %s pid=%d", me, getpid()); #if 0 sigset_t sigs_to_block; @@ -918,6 +949,7 @@ void StopAppService(void *pHandle) { /* Stops the app */ statserv_closedown(); + statserv_reset(); } /* WIN32 */ #else @@ -935,6 +967,7 @@ int statserv_main(int argc, char **argv, statserv_setcontrol(cb); ret = statserv_start (argc, argv); statserv_closedown (); + statserv_reset(); return ret; } #endif