From: Adam Dickmeiss Date: Sat, 5 Jun 2004 07:55:05 +0000 (+0000) Subject: Allow us to stop server (for memory debugging purposes) X-Git-Tag: release.0.0.8.lau~7 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=bf76c3f6ff0e224efce7e47f9f778f6379a3e504;p=simpleserver-moved-to-github.git Allow us to stop server (for memory debugging purposes) --- diff --git a/Makefile.PL b/Makefile.PL index d502bf3..a280ea0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,8 +1,8 @@ use ExtUtils::MakeMaker; -## $Id: Makefile.PL,v 1.3 2004-05-28 20:27:16 sondberg Exp $ +## $Id: Makefile.PL,v 1.4 2004-06-05 07:55:05 adam Exp $ -my $libs = `yaz-config --libs threads` || die "ERROR: Unable to call script: yaz-config"; +my $libs = `yaz-config --libs` || die "ERROR: Unable to call script: yaz-config"; WriteMakefile( 'NAME' => 'Net::Z3950::SimpleServer', diff --git a/SimpleServer.xs b/SimpleServer.xs index 7311dc3..44f182c 100644 --- a/SimpleServer.xs +++ b/SimpleServer.xs @@ -1,5 +1,5 @@ /* - * $Id: SimpleServer.xs,v 1.27 2004-06-04 20:16:04 adam Exp $ + * $Id: SimpleServer.xs,v 1.28 2004-06-05 07:55:05 adam Exp $ * ---------------------------------------------------------------------- * * Copyright (c) 2000-2004, Index Data. @@ -65,8 +65,11 @@ typedef struct { SV *delete_ref; SV *scan_ref; NMEM nmem; + int stop_flag; /* is used to stop server prematurely .. */ } Zfront_handle; +#define ENABLE_STOP_SERVER 0 + SV *init_ref = NULL; SV *close_ref = NULL; SV *sort_ref = NULL; @@ -614,6 +617,12 @@ int bend_search(void *handle, bend_search_rr *rr) { av_push(aref, newSVpv(*basenames++, 0)); } +#if ENABLE_STOP_SERVER + if (rr->num_bases == 1 && !strcmp(rr->basenames[0], "XXstop")) + { + zhandle->stop_flag = 1; + } +#endif href = newHV(); hv_store(href, "SETNAME", 7, newSVpv(rr->setname, 0), 0); hv_store(href, "REPL_SET", 8, newSViv(rr->replace_set), 0); @@ -1188,6 +1197,7 @@ bend_initresult *bend_init(bend_initrequest *q) SAVETMPS; zhandle->nmem = nmem; + zhandle->stop_flag = 0; /*q->bend_sort = bend_sort;*/ if (search_ref) { @@ -1295,7 +1305,7 @@ void bend_close(void *handle) Zfront_handle *zhandle = (Zfront_handle *)handle; SV **temp; CV* handler_cv = 0; - + int stop_flag = 0; if (close_ref) { @@ -1320,9 +1330,12 @@ void bend_close(void *handle) FREETMPS; LEAVE; } + stop_flag = zhandle->stop_flag; nmem_destroy(zhandle->nmem); simpleserver_free(); - + + if (stop_flag) + exit(0); return; }