From: Mike Taylor Date: Wed, 7 Mar 2007 11:25:29 +0000 (+0000) Subject: Add new "-n " option to make the server exit on every n'th X-Git-Tag: CPAN.1.12~101 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=944da8b68f4a7191ce8a989f43b28ff853ac9120;p=simpleserver-moved-to-github.git Add new "-n " option to make the server exit on every n'th search. This is useful for testing the reconnection-robustness of clients. --- diff --git a/ztest.pl b/ztest.pl index 55587ec..c5bec85 100755 --- a/ztest.pl +++ b/ztest.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -## $Id: ztest.pl,v 1.15 2006-04-19 13:17:52 sondberg Exp $ +## $Id: ztest.pl,v 1.16 2007-03-07 11:25:29 mike Exp $ ## ------------------------------------------------------------------ ## ## Copyright (c) 2000-2004, Index Data. @@ -100,8 +100,16 @@ sub my_scan_handler { } +my $_fail_frequency = 0; +my $_counter = 0; + sub my_search_handler { my $args = shift; + + if ($_fail_frequency != 0 && ++$_counter % $_fail_frequency == 0) { + print "Exiting to be nasty to client\n"; + exit(1); + } my $data = [{ name => "Peter Dornan", title => "Spokesman", @@ -166,4 +174,9 @@ my $handler = new Net::Z3950::SimpleServer( SORT => "main::my_sort_handler", FETCH => "main::my_fetch_handler" ); +if (@ARGV >= 2 && $ARGV[0] eq "-n") { + $_fail_frequency = $ARGV[1]; + shift; + shift; +} $handler->launch_server("ztest.pl", @ARGV);