X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fstatserv.c;h=db60db7d7ad1f7f8fb5014d4427150ef97ab8fb8;hp=c58646fe708cb8ef1216925434a9f36e1ebdb86c;hb=c2d4d247b3fe28f7c191fbc3644c8e011e1a4fea;hpb=3d4e0c75cee82cc17fa5da38051b072d9bed61a7 diff --git a/src/statserv.c b/src/statserv.c index c58646f..db60db7 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -1,5 +1,5 @@ /* This file is part of the YAZ toolkit. - * Copyright (C) 1995-2008 Index Data + * Copyright (C) 1995-2010 Index Data * See the file LICENSE for details. */ @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef USE_XTIMOSI #include #endif @@ -94,7 +95,7 @@ statserv_options_block control_block = { "", /* diagnostic output to stderr */ "tcp:@:9999", /* default listener port */ PROTO_Z3950, /* default application protocol */ - 15, /* idle timeout (minutes) */ + 900, /* idle timeout (seconds) */ 1024*1024, /* maximum PDU size (approx.) to allow */ "default-config", /* configuration name to pass to backend */ "", /* set user id */ @@ -208,6 +209,7 @@ static char *nmem_dup_xml_content(NMEM n, xmlNodePtr ptr) } #endif +#if YAZ_HAVE_XML2 static struct gfs_server * gfs_server_new(void) { struct gfs_server *n = (struct gfs_server *) @@ -222,12 +224,12 @@ static struct gfs_server * gfs_server_new(void) n->directory = 0; n->docpath = 0; n->stylesheet = 0; -#if YAZ_HAVE_XML2 n->retrieval = yaz_retrieval_create(); -#endif return n; } +#endif +#if YAZ_HAVE_XML2 static struct gfs_listen * gfs_listen_new(const char *id, const char *address) { @@ -241,6 +243,7 @@ static struct gfs_listen * gfs_listen_new(const char *id, n->address = nmem_strdup(gfs_nmem, address); return n; } +#endif static void gfs_server_chdir(struct gfs_server *gfs) { @@ -326,11 +329,11 @@ int control_association(association *assoc, const char *host, int force_open) return 1; } +#if YAZ_HAVE_XML2 static void xml_config_read(void) { struct gfs_server **gfsp = &gfs_server_list; struct gfs_listen **gfslp = &gfs_listen_list; -#if YAZ_HAVE_XML2 xmlNodePtr ptr = xml_config_get_root(); if (!ptr) @@ -475,9 +478,9 @@ static void xml_config_read(void) gfsp = &(*gfsp)->next; } } -#endif *gfsp = 0; } +#endif static void xml_config_open(void) { @@ -992,7 +995,7 @@ static void listener(IOCHAN h, int event) static void *new_session(void *vp) { - char *a; + const char *a; association *newas; IOCHAN new_chan; COMSTACK new_line = (COMSTACK) vp; @@ -1060,7 +1063,7 @@ static void inetd_connection(int what) COMSTACK line; IOCHAN chan; association *assoc; - char *addr; + const char *addr; if ((line = cs_createbysocket(0, tcpip_type, 0, what))) { @@ -1182,7 +1185,11 @@ statserv_options_block *statserv_getcontrol(void) void statserv_setcontrol(statserv_options_block *block) { - chdir(gfs_root_dir); + if (gfs_root_dir[0]) + { + if (chdir(gfs_root_dir)) + yaz_log(YLOG_WARN|YLOG_ERRNO, "chdir %s", gfs_root_dir); + } #ifdef WIN32 if (init_control_tls) TlsSetValue(current_control_tls, block); @@ -1280,7 +1287,10 @@ static int statserv_sc_main(yaz_sc_t s, int argc, char **argv) close(1); close(2); open("/dev/null", O_RDWR); - dup(0); dup(0); + if (dup(0) == -1) + return 1; + if (dup(0) == -1) + return 1; } xml_config_add_listeners(); @@ -1433,7 +1443,7 @@ int check_options(int argc, char **argv) fprintf(stderr, "%s: Specify positive timeout for -t.\n", me); return(1); } - control_block.idle_timeout = r; + control_block.idle_timeout = strchr(arg, 's') ? r : 60 * r; break; case 'k': if (!arg || !(r = atoi(arg))) @@ -1522,6 +1532,7 @@ int statserv_main(int argc, char **argv, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab