Introduce Z39.50/SRU operation timeout.
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 29 Sep 2009 07:46:11 +0000 (09:46 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 29 Sep 2009 07:46:11 +0000 (09:46 +0200)
Introduce operations timeout. It replaces connect timeout and is the
maximum waiting time before giving up an active operation. Its
default value is 30 seconds.

NEWS
doc/pazpar2_conf.xml
src/client.h
src/connection.c
src/logic.c
src/pazpar2_config.c
src/pazpar2_config.h

diff --git a/NEWS b/NEWS
index 086446a..0f907e9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -12,7 +12,7 @@ must use Content-Type=text/xml.
 
 Timeout values may be given per-service. That's element 'timeout' 
 which takes three attribute values (a subset may be given): 'session',
-'z3950_connect', 'z3950_session'. Option -T is no longer supported
+'z3950_operation', 'z3950_session'. Option -T is no longer supported
 - used to specify session timeout.
 
 Option -t tests the Pazpar2 configuration and returns exit code
index 9d08cbc..cf97dfb 100644 (file)
          Specifies timeout parameters for this service.
          The <literal>timeout</literal>
          element supports the following attributes: 
-         <literal>session</literal>, <literal>z3950_connect</literal>,
+         <literal>session</literal>, <literal>z3950_operation</literal>,
          <literal>z3950_session</literal> which specifies
-         'session timeout', 'Z39.50 connect timeout', 'Z39.50 session timeout'
-         respectively.
+         'session timeout', 'Z39.50 operation timeout',
+         'Z39.50 session timeout' respectively. The Z39.50 operation
+         timeout is the time Pazpar2 will wait for an active Z39.50/SRU
+         operation before it gives up (times out). The Z39.50 session
+         time out is the time Pazpar2 will keep the session alive for
+         an idle session (no operation).
+        </para>
+        <para>
+         The following is recommended but not required:
+         z3950_operation (30) &lt; session (60) &lt; z3950_session (180) .
+         The default values are given in parantheses.
         </para>
        </listitem>
        </varlistentry>
index babaca5..c16c369 100644 (file)
@@ -72,7 +72,7 @@ void client_destroy(struct client *c);
 void client_set_connection(struct client *cl, struct connection *con);
 void client_disconnect(struct client *cl);
 int client_prep_connection(struct client *cl,
-                           int connect_timeout, int session_timeout);
+                           int operation_timeout, int session_timeout);
 void client_start_search(struct client *cl);
 void client_set_session(struct client *cl, struct session *se);
 int client_is_active(struct client *cl);
index cda779c..9acd502 100644 (file)
@@ -63,7 +63,7 @@ struct connection {
         Conn_Connecting,
         Conn_Open
     } state;
-    int connect_timeout;
+    int operation_timeout;
     int session_timeout;
     struct connection *next; // next for same host or next in free list
 };
@@ -134,7 +134,7 @@ void connection_destroy(struct connection *co)
 // Creates a new connection for client, associated with the host of 
 // client's database
 static struct connection *connection_create(struct client *cl,
-                                            int connect_timeout,
+                                            int operation_timeout,
                                             int session_timeout)
 {
     struct connection *new;
@@ -156,7 +156,7 @@ static struct connection *connection_create(struct client *cl,
     client_set_connection(cl, new);
     new->link = 0;
     new->state = Conn_Resolving;
-    new->connect_timeout = connect_timeout;
+    new->operation_timeout = operation_timeout;
     new->session_timeout = session_timeout;
     if (host->ipport)
         connection_connect(new);
@@ -188,6 +188,7 @@ static void non_block_events(struct connection *co)
                     yaz_log(YLOG_LOG, "Error %s from %s",
                             error, client_get_url(cl));
                 }
+                iochan_settimeout(iochan, co->session_timeout);
                 client_set_state(cl, Client_Idle);
             }
             break;
@@ -199,13 +200,13 @@ static void non_block_events(struct connection *co)
             break;
         case ZOOM_EVENT_SEND_APDU:
             client_set_state(co->client, Client_Working);
+            iochan_settimeout(iochan, co->operation_timeout);
             break;
         case ZOOM_EVENT_RECV_APDU:
             break;
         case ZOOM_EVENT_CONNECT:
             yaz_log(YLOG_LOG, "Connected to %s", client_get_url(cl));
             co->state = Conn_Open;
-            iochan_settimeout(iochan, co->session_timeout);
             break;
         case ZOOM_EVENT_RECV_SEARCH:
             client_search_response(cl);
@@ -389,7 +390,7 @@ static int connection_connect(struct connection *con)
     con->link = link;
     con->iochan = iochan_create(0, connection_handler, 0);
     con->state = Conn_Connecting;
-    iochan_settimeout(con->iochan, con->connect_timeout);
+    iochan_settimeout(con->iochan, con->operation_timeout);
     iochan_setdata(con->iochan, con);
     iochan_setsocketfun(con->iochan, socketfun);
     iochan_setmaskfun(con->iochan, maskfun);
@@ -408,7 +409,7 @@ const char *connection_get_url(struct connection *co)
 
 // Ensure that client has a connection associated
 int client_prep_connection(struct client *cl,
-                           int connect_timeout, int session_timeout)
+                           int operation_timeout, int session_timeout)
 {
     struct connection *co;
     struct session *se = client_get_session(cl);
@@ -444,15 +445,15 @@ int client_prep_connection(struct client *cl,
             connection_release(co);
             client_set_connection(cl, co);
             co->client = cl;
+            co->operation_timeout = operation_timeout;
+            co->session_timeout = session_timeout;
             /* tells ZOOM to reconnect if necessary. Disabled becuase
                the ZOOM_connection_connect flushes the task queue */
-            co->connect_timeout = connect_timeout;
-            co->session_timeout = session_timeout;
             ZOOM_connection_connect(co->link, 0, 0);
         }
         else
         {
-            co = connection_create(cl, connect_timeout, session_timeout);
+            co = connection_create(cl, operation_timeout, session_timeout);
         }
     }
 
index e243d58..bcff482 100644 (file)
@@ -566,7 +566,7 @@ enum pazpar2_error_code search(struct session *se,
         else
         {
             no_working++;
-            if (client_prep_connection(cl, se->service->z3950_connect_timeout,
+            if (client_prep_connection(cl, se->service->z3950_operation_timeout,
                     se->service->z3950_session_timeout))
                 client_start_search(cl);
         }
index 959bfcb..4762aa5 100644 (file)
@@ -131,7 +131,7 @@ static struct conf_service *service_init(struct conf_server *server,
     service->server = server;
     service->session_timeout = 60; /* default session timeout */
     service->z3950_session_timeout = 180;
-    service->z3950_connect_timeout = 15;
+    service->z3950_operation_timeout = 30;
 
     service->relevance_pct = 0;
     service->sort_pct = 0;
@@ -481,14 +481,14 @@ static struct conf_service *service_create_static(struct conf_server *server,
                     return 0;
                 }
             }
-            src = xmlGetProp(n, (xmlChar *) "z3950_connect");
+            src = xmlGetProp(n, (xmlChar *) "z3950_operation");
             if (src)
             {
-                service->z3950_connect_timeout = atoi((const char *) src);
+                service->z3950_operation_timeout = atoi((const char *) src);
                 xmlFree(src);
                 if (service->z3950_session_timeout < 9)
                 {
-                    yaz_log(YLOG_FATAL, "Z39.50 connect timeout out of range");
+                    yaz_log(YLOG_FATAL, "Z39.50 operation timeout out of range");
                     return 0;
                 }
             }
index ddd987b..1282cd3 100644 (file)
@@ -109,7 +109,7 @@ struct conf_service
     NMEM nmem;
     int session_timeout;
     int z3950_session_timeout;
-    int z3950_connect_timeout;
+    int z3950_operation_timeout;
 
     int ref_count;
     /* duplicated from conf_server */