X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fstatserv.c;h=be221e211868568003edfc1df55802f776842f4b;hb=4ca818ec201c9dcf5461e419002c95fd2eac620e;hp=c4a7e9d529aeef7e414c1f18e91d0a5cfcde9082;hpb=63d3984ef11179af51a79d202dca15b70403099b;p=yaz-moved-to-github.git diff --git a/server/statserv.c b/server/statserv.c index c4a7e9d..be221e2 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -6,7 +6,7 @@ * NT threaded server code by * Chas Woodfield, Fretwell Downing Informatics. * - * $Id: statserv.c,v 1.90 2003-01-14 08:21:14 adam Exp $ + * $Id: statserv.c,v 1.95 2003-02-20 15:15:04 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 */ @@ -369,6 +370,7 @@ void sigterm(int sig) static void *new_session (void *vp); static int no_sessions = 0; +static int max_sessions = 0; /* UNIX listener */ static void listener(IOCHAN h, int event) @@ -446,7 +448,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) @@ -564,10 +566,16 @@ 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); +#if 1 a = cs_addrstr(new_line); +#else + a = 0; +#endif yaz_log(LOG_LOG, "Starting session %d from %s", no_sessions, a ? a : "[Unknown]"); + if (max_sessions && no_sessions == max_sessions) + control_block.one_shot = 1; if (control_block.threads) { event_loop(&new_chan); @@ -597,7 +605,7 @@ static void inetd_connection(int what) if ((assoc = create_association(chan, line))) { iochan_setdata(chan, assoc); - iochan_settimeout(chan, control_block.idle_timeout * 60); + iochan_settimeout(chan, 60); addr = cs_addrstr(line); yaz_log(LOG_LOG, "Inetd association from %s", addr ? addr : "[UNKNOWN]"); @@ -691,6 +699,10 @@ void statserv_setcontrol(statserv_options_block *block) memcpy(&control_block, block, sizeof(*block)); } +static void statserv_reset(void) +{ +} + int statserv_start(int argc, char **argv) { int ret; @@ -774,7 +786,7 @@ int check_options(int argc, char **argv) int ret = 0, r; char *arg; - while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:", argv, argc, &arg)) != -2) + while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:D:", argv, argc, &arg)) != -2) { switch (ret) { @@ -854,6 +866,9 @@ int check_options(int argc, char **argv) return 1; } break; + case 'D': + max_sessions = atoi(arg); + break; default: fprintf(stderr, "Usage: %s [ -a -v " " -l -u -c -t " @@ -921,6 +936,7 @@ void StopAppService(void *pHandle) { /* Stops the app */ statserv_closedown(); + statserv_reset(); } /* WIN32 */ #else @@ -938,6 +954,7 @@ int statserv_main(int argc, char **argv, statserv_setcontrol(cb); ret = statserv_start (argc, argv); statserv_closedown (); + statserv_reset(); return ret; } #endif