For the generic frontend server, the maximum record size is used as maximum
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 6 Sep 2006 09:35:39 +0000 (09:35 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 6 Sep 2006 09:35:39 +0000 (09:35 +0000)
size of incoming packages (SRU + Z39.50). The value until was previously
only used in Z39.50 Init negotiation and, later, in a session controlled
sizes of records returned. This is controlled using -k option. It can be
specified, per server, with element maximumrecordsize in YAZ' GFS XML config.

NEWS
doc/gfs-virtual.xml
etc/yazgfs.xml
src/seshigh.c
src/statserv.c

diff --git a/NEWS b/NEWS
index 536f12a..200dfc4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+For the generic frontend server, the maximum record size is used as maximum
+size of incoming packages (SRU + Z39.50). The value until was previously 
+only used in Z39.50 Init negotiation and, later, in a session controlled
+sizes of records returned. This is controlled using -k option. It can be
+specified, per server, with element maximumrecordsize in YAZ' GFS XML config.
+
 --- 2.1.28 2006/09/04
 
 TCP/IP comstack uses getaddrinfo now to resolve names. It should be IPV6
index b32589b..593e8bc 100644 (file)
@@ -1,5 +1,5 @@
 <!-- 
-   $Id: gfs-virtual.xml,v 1.6 2006-04-25 11:25:08 marc Exp $
+   $Id: gfs-virtual.xml,v 1.7 2006-09-06 09:35:39 adam Exp $
    Description of the virtual host mechanism in YAZ GFS
    Included in both manual and man page for yaz-ztest
 -->
     </para>
    </listitem>
   </varlistentry>
+
+  <varlistentry><term>element <literal>maximumrecordsize</literal> (optional)</term>
+   <listitem>
+    <para>
+     Specifies maximum record size/message size, in bytes. This
+     value also servers as maximum size of <emphasis>incoming</emphasis>
+     packages (for Record Updates etc). It's the same value as that
+     given by the <literal>-k</literal> option.
+    </para>
+   </listitem>
+  </varlistentry>
+   
  </variablelist>
 </para>
  
index ad435c7..42f3857 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $Id: yazgfs.xml,v 1.5 2006-05-09 13:39:46 adam Exp $ -->
+<!-- $Id: yazgfs.xml,v 1.6 2006-09-06 09:35:40 adam Exp $ -->
 <!-- sample YAZ GFS config file .. see 
   http://indexdata.dk/yaz/doc/server.vhosts.tkl -->
 <yazgfs>
@@ -9,6 +9,7 @@
      <cql2rpn>pqf.properties</cql2rpn>
      <docpath>xsl</docpath>
      <stylesheet>xsl/default.xsl</stylesheet>
+     <maximumrecordsize>2000000</maximumrecordsize>
      <retrievalinfo>
        <retrieval syntax="grs-1"/>
        <retrieval syntax="usmarc" name="F"/>
index 9227158..5132309 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: seshigh.c,v 1.97 2006-09-01 12:40:44 adam Exp $
+ * $Id: seshigh.c,v 1.98 2006-09-06 09:35:41 adam Exp $
  */
 /**
  * \file seshigh.c
@@ -519,9 +519,6 @@ static int srw_bend_init(association *assoc, Z_SRW_diagnostic **d, int *num, Z_S
         yaz_log(log_requestdetail, "srw_bend_init config=%s", cb->configname);
         assoc_init_reset(assoc);
         
-        assoc->maximumRecordSize = 3000000;
-        assoc->preferredMessageSize = 3000000;
-
         if (sr->username)
         {
             Z_IdAuthentication *auth = odr_malloc(assoc->decode, sizeof(*auth));
@@ -2308,13 +2305,12 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
     }
 
     yaz_log(log_requestdetail, "Negotiated to v%d: %s", assoc->version, options);
-    assoc->maximumRecordSize = *req->maximumRecordSize;
 
-    if (cb && assoc->maximumRecordSize > cb->maxrecordsize)
-        assoc->maximumRecordSize = cb->maxrecordsize;
-    assoc->preferredMessageSize = *req->preferredMessageSize;
-    if (assoc->preferredMessageSize > assoc->maximumRecordSize)
-        assoc->preferredMessageSize = assoc->maximumRecordSize;
+    if (*req->maximumRecordSize < assoc->maximumRecordSize)
+        assoc->maximumRecordSize = *req->maximumRecordSize;
+
+    if (*req->preferredMessageSize < assoc->preferredMessageSize)
+        assoc->preferredMessageSize = *req->preferredMessageSize;
 
     resp->preferredMessageSize = &assoc->preferredMessageSize;
     resp->maximumRecordSize = &assoc->maximumRecordSize;
@@ -2327,7 +2323,7 @@ static Z_APDU *process_initRequest(association *assoc, request *reqb)
                 assoc->init->implementation_name,
                 odr_prepend(assoc->encode, "GFS", resp->implementationName));
 
-    version = odr_strdup(assoc->encode, "$Revision: 1.97 $");
+    version = odr_strdup(assoc->encode, "$Revision: 1.98 $");
     if (strlen(version) > 10)   /* check for unexpanded CVS strings */
         version[strlen(version)-2] = '\0';
     resp->implementationVersion = odr_prepend(assoc->encode,
index 7d4af0b..bed22d0 100644 (file)
@@ -5,7 +5,7 @@
  * NT threaded server code by
  *   Chas Woodfield, Fretwell Downing Informatics.
  *
- * $Id: statserv.c,v 1.40 2006-07-07 13:02:21 marc Exp $
+ * $Id: statserv.c,v 1.41 2006-09-06 09:35:42 adam Exp $
  */
 
 /**
@@ -301,23 +301,30 @@ int control_association(association *assoc, const char *host, int force_open)
                 assoc->server = gfs;
                 assoc->last_control = &gfs->cb;
                 statserv_setcontrol(&gfs->cb);
+                
                 gfs_server_chdir(gfs);
-                yaz_log(YLOG_DEBUG, "server select: %s", gfs->cb.configname);
-                return 1;
+                break;
             }
         }
-        statserv_setcontrol(0);
-        assoc->last_control = 0;
-        yaz_log(YLOG_DEBUG, "server select: no match");
-        return 0;
+        if (!gfs)
+        {
+            statserv_setcontrol(0);
+            assoc->last_control = 0;
+            return 0;
+        }
     }
     else
     {
         statserv_setcontrol(&control_block);
         assoc->last_control = &control_block;
-        yaz_log(YLOG_DEBUG, "server select: config=%s", control_block.configname);
-        return 1;
     }
+    yaz_log(YLOG_DEBUG, "server select: config=%s", 
+            assoc->last_control->configname);
+
+    assoc->maximumRecordSize = assoc->last_control->maxrecordsize;
+    assoc->preferredMessageSize = assoc->last_control->maxrecordsize;
+    cs_set_max_recv_bytes(assoc->client_link, assoc->maximumRecordSize);
+    return 1;
 }
 
 static void xml_config_read()
@@ -360,6 +367,7 @@ static void xml_config_read()
             xmlNodePtr ptr;
             const char *listenref = 0;
             const char *id = 0;
+            struct gfs_server *gfs;
 
             for ( ; attr; attr = attr->next)
                 if (!xmlStrcmp(attr->name, BAD_CAST "listenref") 
@@ -372,8 +380,8 @@ static void xml_config_read()
                 else
                     yaz_log(YLOG_WARN, "Unknown attribute '%s' for server",
                             attr->name);
-            *gfsp = gfs_server_new();
-            (*gfsp)->server_node_ptr = ptr_server;
+            gfs = *gfsp = gfs_server_new();
+            gfs->server_node_ptr = ptr_server;
             if (listenref)
             {
                 int id_no;
@@ -381,7 +389,7 @@ static void xml_config_read()
                 for (id_no = 1; gl; gl = gl->next, id_no++)
                     if (gl->id && !strcmp(gl->id, listenref))
                     {
-                        (*gfsp)->listen_ref = id_no;
+                        gfs->listen_ref = id_no;
                         break;
                     }
                 if (!gl)
@@ -394,36 +402,41 @@ static void xml_config_read()
                     continue;
                 if (!strcmp((const char *) ptr->name, "host"))
                 {
-                    (*gfsp)->host = nmem_dup_xml_content(gfs_nmem,
+                    gfs->host = nmem_dup_xml_content(gfs_nmem,
                                                          ptr->children);
                 }
                 else if (!strcmp((const char *) ptr->name, "config"))
                 {
-                    strcpy((*gfsp)->cb.configname,
+                    strcpy(gfs->cb.configname,
                            nmem_dup_xml_content(gfs_nmem, ptr->children));
                 }
                 else if (!strcmp((const char *) ptr->name, "cql2rpn"))
                 {
-                    (*gfsp)->cql_transform = cql_transform_open_fname(
+                    gfs->cql_transform = cql_transform_open_fname(
                         nmem_dup_xml_content(gfs_nmem, ptr->children)
                         );
                 }
                 else if (!strcmp((const char *) ptr->name, "directory"))
                 {
-                    (*gfsp)->directory = 
+                    gfs->directory = 
                         nmem_dup_xml_content(gfs_nmem, ptr->children);
                 }
                 else if (!strcmp((const char *) ptr->name, "docpath"))
                 {
-                    (*gfsp)->docpath = 
+                    gfs->docpath = 
                         nmem_dup_xml_content(gfs_nmem, ptr->children);
                 }
+                else if (!strcmp((const char *) ptr->name, "maximumrecordsize"))
+                {
+                    gfs->cb.maxrecordsize = atoi(
+                        nmem_dup_xml_content(gfs_nmem, ptr->children));
+                }
                 else if (!strcmp((const char *) ptr->name, "stylesheet"))
                 {
                     char *s = nmem_dup_xml_content(gfs_nmem, ptr->children);
-                    (*gfsp)->stylesheet = 
+                    gfs->stylesheet = 
                         nmem_malloc(gfs_nmem, strlen(s) + 2);
-                    sprintf((*gfsp)->stylesheet, "/%s", s);
+                    sprintf(gfs->stylesheet, "/%s", s);
                 }
                 else if (!strcmp((const char *) ptr->name, "explain"))
                 {
@@ -431,10 +444,10 @@ static void xml_config_read()
                 }
                 else if (!strcmp((const char *) ptr->name, "retrievalinfo"))
                 {
-                    if (yaz_retrieval_configure((*gfsp)->retrieval, ptr))
+                    if (yaz_retrieval_configure(gfs->retrieval, ptr))
                     {       
                         yaz_log(YLOG_FATAL, "%s in config %s",
-                                yaz_retrieval_get_error((*gfsp)->retrieval),
+                                yaz_retrieval_get_error(gfs->retrieval),
                                 control_block.xml_config);
                         exit(1);
                     }