From: Adam Dickmeiss Date: Thu, 17 Mar 2011 08:19:22 +0000 (+0100) Subject: GFS: make statserv_main return for one-shot mode. X-Git-Tag: v4.2.0~54^2~4 X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=commitdiff_plain;h=c1250b6b91fc106645f28bff1d6188936434a494 GFS: make statserv_main return for one-shot mode. Bug #4064. --- diff --git a/src/seshigh.c b/src/seshigh.c index e739d3a..0a3f9fa 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -227,10 +227,6 @@ void destroy_association(association *h) request_delq(&h->outgoing); xfree(h); xmalloc_trav("session closed"); - if (cb && cb->one_shot) - { - exit(0); - } } static void do_close_req(association *a, int reason, char *message, diff --git a/src/statserv.c b/src/statserv.c index ab15c21..7560058 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -610,6 +610,8 @@ static void xml_config_bend_stop(void) } } +static void remove_listeners(void); + /* * handle incoming connect requests. * The dynamic mode is a bit tricky mostly because we want to avoid @@ -909,6 +911,9 @@ static void listener(IOCHAN h, int event) return; } + if (control_block.one_shot) + remove_listeners(); + yaz_log(log_sessiondetail, "Connect from %s", cs_addrstr(new_line)); no_sessions++; @@ -1129,6 +1134,13 @@ static int add_listener(char *where, int listen_id) return 0; /* OK */ } +static void remove_listeners(void) +{ + IOCHAN l = pListener; + for (; l; l = l->next) + iochan_destroy(l); +} + #ifndef WIN32 /* UNIX only (for windows we don't need to catch the signals) */ static void catchchld(int num)