GFS: no-keepalive option, mostly for testing
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 23 Sep 2010 12:37:07 +0000 (14:37 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 23 Sep 2010 12:37:07 +0000 (14:37 +0200)
The no-keepalive option is enabled for GFS by supplying option -K.

doc/gfs-options.xml
doc/gfs-synopsis.xml
doc/yaz-ztest-man.xml
include/yaz/backend.h
src/seshigh.c
src/statserv.c

index 9af6f0e..c3ed444 100644 (file)
    </para></listitem>
  </varlistentry>
 
+ <varlistentry><term><literal>-K</literal></term>
+  <listitem><para>
+    Forces no-keepalive for HTTP sessions. By default GFS will keep
+    sessions alive for HTTP 1.1 sessions (as defined by the standard).
+    Using this option will force GFS to close the connection for each
+    operation.
+   </para></listitem>
+ </varlistentry>
+
  <varlistentry><term><literal>-r </literal>
    <replaceable>size</replaceable></term>
   <listitem><para>
index 81266c6..babc5e3 100644 (file)
@@ -17,6 +17,7 @@
  <arg choice="opt"><option>-C <replaceable>fname</replaceable></option></arg>
  <arg choice="opt"><option>-t <replaceable>minutes</replaceable></option></arg>
  <arg choice="opt"><option>-k <replaceable>kilobytes</replaceable></option></arg>
+ <arg choice="opt"><option>-K</option></arg>
  <arg choice="opt"><option>-d <replaceable>daemon</replaceable></option></arg>
  <arg choice="opt"><option>-w <replaceable>dir</replaceable></option></arg>
  <arg choice="opt"><option>-p <replaceable>pidfile</replaceable></option></arg>
index 14f743c..4707a97 100644 (file)
@@ -24,7 +24,7 @@
  
  <refnamediv>
   <refname>yaz-ztest</refname>
-  <refpurpose>Z39.50 Test Server</refpurpose>
+  <refpurpose>Z39.50/SRU Test Server</refpurpose>
  </refnamediv>
  
  <refsynopsisdiv>
@@ -32,9 +32,9 @@
  </refsynopsisdiv>
  <refsect1><title>DESCRIPTION</title>
   <para>
-   <command>yaz-ztest</command> is a Z39.50 test server that uses
-   the YAZ generic frontend server API.
-   The server acts as a real Z39.50 server but does not use a database.
+   <command>yaz-ztest</command> is a Z39.50/SRU test server that uses
+   the YAZ generic frontend server (GFS) API.
+   The server acts as a real Z39.50/SRU server but does not use a database.
    It returns a random hit count and returns a subset of a few built-in
    records.
   </para>
index c781fa3..5c04a60 100644 (file)
@@ -358,6 +358,7 @@ typedef struct statserv_options_block
     int background;                 /**< auto daemon */
     char cert_fname[128];           /**< SSL certificate fname */
     char xml_config[128];           /**< XML config filename */
+    int keepalive;                  /**< keep alive if HTTP 1.1 (default: 1) */
 } statserv_options_block;
 
 YAZ_EXPORT int statserv_main(
index 48e0a4b..378b130 100644 (file)
@@ -1907,7 +1907,7 @@ static void process_http_request(association *assoc, request *req)
             keepalive = 1;
         hres->version = "1.1";
     }
-    if (!keepalive)
+    if (!keepalive || !assoc->last_control->keepalive)
     {
         z_HTTP_header_add(o, &hres->headers, "Connection", "close");
         assoc->state = ASSOC_DEAD;
index 4def68a..d340a17 100644 (file)
@@ -117,7 +117,8 @@ statserv_options_block control_block = {
     "",                         /* PID fname */
     0,                          /* background daemon */
     "",                         /* SSL certificate filename */
-    ""                          /* XML config filename */
+    "",                         /* XML config filename */
+    1                           /* keepalive */
 };
 
 static int max_sessions = 0;
@@ -1259,7 +1260,7 @@ int check_options(int argc, char **argv)
 
     get_logbits(1); 
 
-    while ((ret = options("1a:iszSTl:v:u:c:w:t:k:d:A:p:DC:f:m:r:",
+    while ((ret = options("1a:iszSTl:v:u:c:w:t:k:Kd:A:p:DC:f:m:r:",
                           argv, argc, &arg)) != -2)
     {
         switch (ret)
@@ -1337,6 +1338,9 @@ int check_options(int argc, char **argv)
             }
             control_block.maxrecordsize = r * 1024;
             break;
+        case 'K':
+            control_block.keepalive = 0;
+            break;
         case 'i':
             control_block.inetd = 1;
             break;