X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fstatserv.c;h=7f23e16dfc6a7e2dcc5ac23589f552b002f05603;hb=be821514c869d68186361b5aab6bbfd1aa60e087;hp=bad214c582cdcc11c476824c5ed1079dfb85699d;hpb=7d7cc0b18839b9a78048041d882c1f3baf006c29;p=yaz-moved-to-github.git diff --git a/src/statserv.c b/src/statserv.c index bad214c..7f23e16 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -1,11 +1,11 @@ /* - * Copyright (C) 1995-2006, Index Data ApS + * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * * NT threaded server code by * Chas Woodfield, Fretwell Downing Informatics. * - * $Id: statserv.c,v 1.42 2006-09-14 13:50:24 adam Exp $ + * $Id: statserv.c,v 1.47 2007-01-19 10:29:13 adam Exp $ */ /** @@ -85,8 +85,7 @@ static statserv_options_block *current_control_block = 0; /* * default behavior. */ -#define STAT_DEFAULT_LOG_LEVEL "none,fatal,warn,log,server,session,request" -/* the 'none' clears yaz' own default settings, including [log] */ +#define STAT_DEFAULT_LOG_LEVEL "server,session,request" int check_options(int argc, char **argv); statserv_options_block control_block = { @@ -151,7 +150,7 @@ static xmlDocPtr xml_config_doc = 0; #endif #if YAZ_HAVE_XML2 -static xmlNodePtr xml_config_get_root() +static xmlNodePtr xml_config_get_root(void) { xmlNodePtr ptr = 0; if (xml_config_doc) @@ -212,7 +211,7 @@ static char *nmem_dup_xml_content(NMEM n, xmlNodePtr ptr) } #endif -static struct gfs_server * gfs_server_new() +static struct gfs_server * gfs_server_new(void) { struct gfs_server *n = nmem_malloc(gfs_nmem, sizeof(*n)); memcpy(&n->cb, &control_block, sizeof(control_block)); @@ -327,7 +326,7 @@ int control_association(association *assoc, const char *host, int force_open) return 1; } -static void xml_config_read() +static void xml_config_read(void) { struct gfs_server **gfsp = &gfs_server_list; struct gfs_listen **gfslp = &gfs_listen_list; @@ -466,7 +465,7 @@ static void xml_config_read() *gfsp = 0; } -static void xml_config_open() +static void xml_config_open(void) { if (!getcwd(gfs_root_dir, FILENAME_MAX)) { @@ -509,7 +508,7 @@ static void xml_config_open() #endif } -static void xml_config_close() +static void xml_config_close(void) { #if YAZ_HAVE_XML2 if (xml_config_doc) @@ -529,7 +528,7 @@ static void xml_config_close() #endif } -static void xml_config_add_listeners() +static void xml_config_add_listeners(void) { struct gfs_listen *gfs = gfs_listen_list; int id_no; @@ -541,7 +540,7 @@ static void xml_config_add_listeners() } } -static void xml_config_bend_start() +static void xml_config_bend_start(void) { if (control_block.xml_config[0]) { @@ -567,7 +566,7 @@ static void xml_config_bend_start() } } -static void xml_config_bend_stop() +static void xml_config_bend_stop(void) { if (control_block.xml_config[0]) { @@ -1112,7 +1111,11 @@ static int add_listener(char *where, int listen_id) if (cs_bind(l, ap, CS_SERVER) < 0) { - yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where); + if (cs_errno(l) == CSYSERR) + yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to bind to %s", where); + else + yaz_log(YLOG_FATAL, "Failed to bind to %s: %s", where, + cs_strerror(l)); cs_close (l); return -1; } @@ -1337,19 +1340,10 @@ int check_options(int argc, char **argv) int ret = 0, r; char *arg; - if (getenv("YAZ_LOG") == 0) { - /* - * Set default log level. We want to avoid doing this if the - * user has already explicitly specified a preferred default - * log-level, hence the inelegant peek at the YAZ_LOG - * environment variable that will subsequently be interpreted - * by the YAZ logging module itself. - */ - yaz_log_init_level(yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL)); - } - + yaz_log_init_level(yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL)); get_logbits(1); - while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:m:", + + while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:m:r:", argv, argc, &arg)) != -2) { switch (ret) @@ -1395,12 +1389,10 @@ int check_options(int argc, char **argv) } yaz_log_time_format(arg); break; - case 'v': { - int default_level = yaz_log_mask_str(STAT_DEFAULT_LOG_LEVEL); - yaz_log_init_level(yaz_log_mask_str_x(arg, default_level)); + case 'v': + yaz_log_init_level(yaz_log_mask_str(arg)); get_logbits(1); break; - } case 'a': option_copy(control_block.apdufile, arg); break; @@ -1459,6 +1451,14 @@ int check_options(int argc, char **argv) case 'D': control_block.background = 1; break; + case 'r': + if (!arg || !(r = atoi(arg))) + { + fprintf(stderr, "%s: Specify positive size for -r.\n", me); + return(1); + } + yaz_log_init_max_size(r * 1024); + break; default: fprintf(stderr, "Usage: %s [ -a -v " " -l -u -c -t "