From 87fdb8465b6f9a7e90a022de67e9dbbb57c4c5c9 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 19 Sep 2006 19:41:32 +0000 Subject: [PATCH] Added ZOOM Keepalive/reconnect test utility. --- zoom/.cvsignore | 1 + zoom/Makefile.am | 5 +++-- zoom/zoom-ka.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 zoom/zoom-ka.c diff --git a/zoom/.cvsignore b/zoom/.cvsignore index 78b9d17..f8ba7d9 100644 --- a/zoom/.cvsignore +++ b/zoom/.cvsignore @@ -15,4 +15,5 @@ zoomtst8 zoomtst9 zoomtst10 zoom-benchmark +zoom-ka *.lo diff --git a/zoom/Makefile.am b/zoom/Makefile.am index 86cdff3..1a4cef2 100644 --- a/zoom/Makefile.am +++ b/zoom/Makefile.am @@ -1,10 +1,10 @@ -## $Id: Makefile.am,v 1.20 2006-08-11 12:57:31 adam Exp $ +## $Id: Makefile.am,v 1.21 2006-09-19 19:41:32 adam Exp $ ## Copyright (C) 2001, Index Data AM_CPPFLAGS = -I$(top_srcdir)/include $(XML2_CFLAGS) bin_PROGRAMS = zoomsh -noinst_PROGRAMS = zoomtst1 zoomtst2 zoomtst3 zoomtst4 zoomtst5 zoomtst6 zoomtst7 zoomtst8 zoomtst9 zoomtst10 zoom-benchmark +noinst_PROGRAMS = zoomtst1 zoomtst2 zoomtst3 zoomtst4 zoomtst5 zoomtst6 zoomtst7 zoomtst8 zoomtst9 zoomtst10 zoom-benchmark zoom-ka LDADD = ../src/libyaz.la $(READLINE_LIBS) @@ -20,5 +20,6 @@ zoomtst9_SOURCES = zoomtst9.c zoomtst10_SOURCES = zoomtst10.c zoomsh_SOURCES = zoomsh.c zoom_benchmark_SOURCES = zoom-benchmark.c +zoom_ka_SOURCES = zoom-ka.c diff --git a/zoom/zoom-ka.c b/zoom/zoom-ka.c new file mode 100644 index 0000000..83252b3 --- /dev/null +++ b/zoom/zoom-ka.c @@ -0,0 +1,64 @@ +/* $Id: zoom-ka.c,v 1.1 2006-09-19 19:41:32 adam Exp $ */ + +/** \file zoom-ka.c + \brief Test ZOOM Keepalive / reconnect +*/ + +#include +#include +#include +#include +#include + +#include +#include +#include + +int main(int argc, char **argv) +{ + ZOOM_connection z; + ZOOM_options o = ZOOM_options_create (); + const char *errmsg, *addinfo; + + if (argc != 4) + { + fprintf (stderr, "usage:\nzoom-ka sleepinterval target query\n"); + exit(1); + } + /* async mode */ + ZOOM_options_set (o, "async", "1"); + + z = ZOOM_connection_create(o); + + while(1) + { + int i, error; + ZOOM_resultset rset; + ZOOM_connection_connect (z, argv[2], 0); + rset = ZOOM_connection_search_pqf(z, argv[3]); + + while ((i = ZOOM_event(1, &z))) + { + printf ("no = %d event = %d\n", i-1, + ZOOM_connection_last_event(z)); + } + if ((error = ZOOM_connection_error(z, &errmsg, &addinfo))) + { + fprintf(stderr, "%s error: %s (%d) %s\n", + ZOOM_connection_option_get(z, "host"), + errmsg, error, addinfo); + } + ZOOM_resultset_destroy(rset); + sleep(atoi(argv[1])); + } + ZOOM_connection_destroy (z); + ZOOM_options_destroy(o); +} +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + -- 1.7.10.4