X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=server%2Fstatserv.c;h=9305cdfe9b9be954613e80ca5d65ff3b834ec079;hb=c365561ca2d2f7b16dd287e524abc616eba9b9fc;hp=b7759f3f6d36245631ac62c7e3942d5b71350758;hpb=26fdcc5e41254131ef755b14243c19d202b14d8e;p=yaz-moved-to-github.git diff --git a/server/statserv.c b/server/statserv.c index b7759f3..9305cdf 100644 --- a/server/statserv.c +++ b/server/statserv.c @@ -7,7 +7,21 @@ * Chas Woodfield, Fretwell Downing Datasystems. * * $Log: statserv.c,v $ - * Revision 1.53 1999-02-02 13:57:39 adam + * Revision 1.57 1999-07-06 12:17:15 adam + * Added option -1 that runs server once (for profiling purposes). + * + * Revision 1.56 1999/06/10 11:45:30 adam + * Added bend_start, bend_stop handlers and removed pre_init. + * Handlers bend_start/bend_stop are called when service/daemon is + * started/stopped. + * + * Revision 1.55 1999/06/10 09:18:54 adam + * Modified so that pre_init is called when service/server is started. + * + * Revision 1.54 1999/04/16 14:45:55 adam + * Added interface for tcpd wrapper for access control. + * + * Revision 1.53 1999/02/02 13:57:39 adam * Uses preprocessor define WIN32 instead of WINDOWS to build code * for Microsoft WIN32. * @@ -187,7 +201,6 @@ * */ -#include #include #include #ifdef WIN32 @@ -203,9 +216,9 @@ #include #include -#include #include #include +#include #ifdef USE_XTIMOSI #include #endif @@ -223,6 +236,7 @@ static char *me = "statserver"; int check_options(int argc, char **argv); statserv_options_block control_block = { 1, /* dynamic mode */ + 0, /* one shot (single session) */ LOG_DEFAULT_LEVEL, /* log level */ "", /* no PDUs */ "", /* diagnostic output to stderr */ @@ -232,8 +246,11 @@ statserv_options_block control_block = { 1024*1024, /* maximum PDU size (approx.) to allow */ "default-config", /* configuration name to pass to backend */ "", /* set user id */ - NULL, /* pre init handler */ + 0, /* bend_start handler */ + 0, /* bend_stop handler */ check_options, /* Default routine, for checking the run-time arguments */ + check_ip_tcpd, + "", 0 /* default value for inet deamon */ #ifdef WIN32 @@ -398,6 +415,8 @@ void statserv_closedown() free(pThreadHandles); } + if (control_block.bend_stop) + (*control_block.bend_stop)(&control_block); /* No longer require the critical section, since all threads are dead */ DeleteCriticalSection(&Thread_CritSect); } @@ -509,19 +528,6 @@ void statserv_closedown() iochan_destroy(p); } -static int check_ip(void *cd, const char *addr, int len, int type) -{ - const unsigned char *ip = (const unsigned char *) addr; - int i; - char str[64]; - - sprintf (str, "%u", *ip); - for (i = 1; i<4; i++) - sprintf (str + strlen(str), ".%u", ip[i]); - logf (LOG_DEBUG, "ip %s", str); - return 0; -} - static void listener(IOCHAN h, int event) { COMSTACK line = (COMSTACK) iochan_getdata(h); @@ -589,7 +595,8 @@ static void listener(IOCHAN h, int event) return; } } - if ((res = cs_listen_check(line, 0, 0, check_ip, 0)) < 0) + if ((res = cs_listen_check(line, 0, 0, control_block.check_ip, + control_block.daemon_name)) < 0) { logf(LOG_WARN, "cs_listen failed"); return; @@ -808,13 +815,13 @@ int statserv_start(int argc, char **argv) if (control_block.options_func(argc, argv)) return(1); + if (control_block.bend_start) + (*control_block.bend_start)(&control_block); #ifndef WIN32 if (control_block.inetd) inetd_connection(control_block.default_proto); else { - if (control_block.pre_init) - (*control_block.pre_init)(&control_block); if (control_block.dynamic) signal(SIGCHLD, catchchld); } @@ -855,13 +862,17 @@ int check_options(int argc, char **argv) int ret = 0, r; char *arg; - while ((ret = options("a:iszSl:v:u:c:w:t:k:", argv, argc, &arg)) != -2) + while ((ret = options("1a:iszSl:v:u:c:w:t:k:d:", argv, argc, &arg)) != -2) { switch (ret) { case 0: add_listener(arg, control_block.default_proto); break; + case '1': + control_block.one_shot = 1; + control_block.dynamic = 0; + break; case 'z': control_block.default_proto = PROTO_Z3950; break; @@ -888,6 +899,9 @@ int check_options(int argc, char **argv) case 'c': strcpy(control_block.configname, arg ? arg : ""); break; + case 'd': + strcpy(control_block.daemon_name, arg ? arg : ""); + break; case 't': if (!arg || !(r = atoi(arg))) { @@ -899,7 +913,7 @@ int check_options(int argc, char **argv) case 'k': if (!arg || !(r = atoi(arg))) { - fprintf(stderr, "%s: Specify positive timeout for -t.\n", me); + fprintf(stderr, "%s: Specify positive size for -k.\n", me); return(1); } control_block.maxrecordsize = r * 1024; @@ -917,7 +931,7 @@ int check_options(int argc, char **argv) default: fprintf(stderr, "Usage: %s [ -i -a -v " " -l -u -c -t " - " -k " + " -k -d " " -zsS -w ... ]\n", me); return(1); }