X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fstatserv.c;h=b041f1a9d3ad8be3feb3772c284928033d2736e9;hb=a66975fb6d7c8877a2eaa3861aaeb4952d398d7d;hp=2e01fbb31fc197c28fc4ad250c19b5e67e3742a7;hpb=db585d7fcb8319fa86543eb062df7fdaf16858c6;p=yaz-moved-to-github.git diff --git a/server/statserv.c b/server/statserv.c index 2e01fbb..b041f1a 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.93 2003-02-17 21:23:31 adam Exp $ + * $Id: statserv.c,v 1.97 2003-02-23 14:46:10 adam Exp $ */ #include @@ -80,6 +80,8 @@ statserv_options_block control_block = { 0 /* SOAP handlers */ }; +static int max_sessions = 0; + /* * handle incoming connect requests. * The dynamic mode is a bit tricky mostly because we want to avoid @@ -566,9 +568,15 @@ static void *new_session (void *vp) iochan_setdata(new_chan, newas); 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); @@ -598,7 +606,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]"); @@ -650,7 +658,8 @@ static int add_listener(char *where, int what) } if (cs_bind(l, ap, CS_SERVER) < 0) { - yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", where); + yaz_log(LOG_FATAL|LOG_ERRNO, "Failed to bind to %s", + where, errno); cs_close (l); return -1; } @@ -692,31 +701,8 @@ 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) @@ -802,7 +788,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) { @@ -882,6 +868,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 "