Merge branch 'master' into graceful_stop
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Apr 2012 11:57:31 +0000 (13:57 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 18 Apr 2012 11:57:31 +0000 (13:57 +0200)
IDMETA
NEWS
debian/changelog
doc/zoom.xml
etc/config-zoom.xml
src/filter_zoom.cpp
win/makefile
xml/schema/filter_zoom.rnc

diff --git a/IDMETA b/IDMETA
index 7011884..4743175 100644 (file)
--- a/IDMETA
+++ b/IDMETA
@@ -1,3 +1,3 @@
 DEBIAN_DIST="wheezy squeeze lenny"
 UBUNTU_DIST="oneiric natty maverick lucid"
-VERSION=1.3.28
+VERSION=1.3.29
diff --git a/NEWS b/NEWS
index f0beb08..d20a76c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,18 @@
+--- 1.3.29 2012/04/18
+
+zoom: may read cf-proxy's config settings.
+This reduces manual configuration of the content proxy server host.
+The ZOOM module will use the old style session.proxyhost if "server"
+is given (deprecated) and use the new style proxyhost/session if
+"config_file" is in use.
+
+frontend_net: remove incoming requests that can not be handled
+Requests in queue for filter frontend_net are removed if client
+closes connection for the session and request is not yet handled.
+
+sru_z3950: serialize requests. This is to ensure that pipelined
+HTTP requests are handled properly.
+
 --- 1.3.28 2012/04/04
 
 New class, wrbuf, that wraps YAZ' WRBUF.
index f0fe8fb..13939bc 100644 (file)
@@ -1,3 +1,9 @@
+metaproxy (1.3.29-1indexdata) unstable; urgency=low
+
+  * Upstream.
+
+ -- Adam Dickmeiss <adam@indexdata.dk>  Wed, 18 Apr 2012 13:18:41 +0200
+
 metaproxy (1.3.28-1indexdata) unstable; urgency=low
 
   * Upstream.
index ef6974a..f88c5b4 100644 (file)
    </para>
    <variablelist>
     <varlistentry>
+     <term>attribute <literal>config_file</literal></term>
+     <listitem>
+      <para>
+       Specifies the file that configures the cf-proxy system. Metaproxy
+       uses setting <literal>sessiondir</literal> and
+       <literal>proxyhostname</literal> from that file to configure
+       name of proxy host and directory of parameter files for the cf-proxy.
+      </para>
+     </listitem>
+    </varlistentry>
+    <varlistentry>
      <term>attribute <literal>server</literal></term>
      <listitem>
       <para>
        host[:port]. That is without a method (such as HTTP) and optional
        port number.
       </para>
+      <note>
+       <para>
+       This setting is deprecated. Use the config_file (above)
+       to inform about the proxy server.
+       </para>
+      </note>
      </listitem>
     </varlistentry>
     <varlistentry>
        using the mkstemp(3) system call. The default value of this
        setting is <literal>/tmp/cf.XXXXXX.p</literal>.
       </para>
+      <note>
+       <para>
+       This setting is deprecated. Use the config_file (above)
+       to inform about the session file area.
+       </para>
+      </note>
      </listitem>
     </varlistentry>
    </variablelist>
index b6be3fd..938d97a 100644 (file)
@@ -29,8 +29,8 @@
            <cclmap_ti>1=4 s=pw t=l,r</cclmap_ti>
            <requestSyntax>usmarc</requestSyntax>
            <transform>tmarc.xsl</transform>
-           <urlRecipe>http://sever.com?title=${md-title[\s+/+/g]}</urlRecipe>
-           <zurl>localhost:9998/db01</zurl>
+           <urlRecipe>http://sever.com?title=${md-title[\s+/+/g]}&amp;parm=1</urlRecipe>
+           <zurl>localhost:9998/Default?search-delay=2&amp;present-delay=2</zurl>
            <contentConnector>heikki/content1</contentConnector>
          </record>
          <record>
         </qual>
       </cclmap>
       <contentProxy
-         server="hpxy.indexdata.com"
-         tmp_file="/tmp/cf.XXXXXX.p"
+         config_file="/etc/cf-proxy/cproxy.cfg"
       />
       <log apdu="true"/>
       <zoom timeout="20"/>
       <filter refid="frontend"/>
       <filter type="log">
         <message>F</message>
+       <category apdu="false" session="true"/>
       </filter>
       <filter type="sru_z3950"/>
       <filter type="session_shared">
-        <resultset ttl="1"/>
+        <resultset ttl="0" restart="false"/>
         <session ttl="60" max="100"/>
       </filter>
       <filter type="log">
         <message>B</message>
-       <category apdu="true"/>
+       <category apdu="false" session="true"/>
       </filter>
       <filter refid="backend"/>
       <filter type="bounce"/>
index bf6f4ab..34b3084 100644 (file)
@@ -91,7 +91,7 @@ namespace metaproxy_1 {
             std::string m_frontend_database;
             SearchablePtr sptr;
             xsltStylesheetPtr xsp;
-            std::string content_session_id;
+            std::string cproxy_host;
             bool enable_cproxy;
             bool enable_explain;
             xmlDoc *explain_doc;
@@ -201,6 +201,7 @@ namespace metaproxy_1 {
             std::string file_path;
             std::string content_proxy_server;
             std::string content_tmp_file;
+            std::string content_config_file;
             bool apdu_log;
             CCL_bibset bibset;
             std::string element_transform;
@@ -622,7 +623,6 @@ void yf::Zoom::Impl::configure(const xmlNode *ptr, bool test_only,
     std::string explain_xslt_fname;
     std::string record_xslt_fname;
 
-    content_tmp_file = "/tmp/cf.XXXXXX.p";
     if (path && *path)
     {
         file_path = path;
@@ -695,9 +695,19 @@ void yf::Zoom::Impl::configure(const xmlNode *ptr, bool test_only,
             for (attr = ptr->properties; attr; attr = attr->next)
             {
                 if (!strcmp((const char *) attr->name, "server"))
+                {
+                    yaz_log(YLOG_WARN,
+                            "contentProxy's server attribute is deprecated");
+                    yaz_log(YLOG_LOG, 
+                            "Specify config_file instead. For example:");
+                    yaz_log(YLOG_LOG, 
+                            " content_file=\"/etc/cf-proxy/cproxy.cfg\"");
                     content_proxy_server = mp::xml::get_text(attr->children);
+                }
                 else if (!strcmp((const char *) attr->name, "tmp_file"))
                     content_tmp_file = mp::xml::get_text(attr->children);
+                else if (!strcmp((const char *) attr->name, "config_file"))
+                    content_config_file = mp::xml::get_text(attr->children);
                 else
                     throw mp::filter::FilterException(
                         "Bad attribute " + std::string((const char *)
@@ -820,16 +830,98 @@ bool yf::Zoom::Frontend::create_content_session(mp::Package &package,
 {
     if (b->sptr->contentConnector.length())
     {
-        char *fname = (char *) xmalloc(m_p->content_tmp_file.length() + 8);
-        strcpy(fname, m_p->content_tmp_file.c_str());
+        std::string proxyhostname;
+        std::string tmp_file;
+        bool legacy_format = false;
+
+        if (m_p->content_proxy_server.length())
+        {
+            proxyhostname = m_p->content_proxy_server;
+            legacy_format = true;
+        }
+            
+        if (m_p->content_tmp_file.length())
+            tmp_file = m_p->content_tmp_file;
+
+        if (m_p->content_config_file.length())
+        {
+            FILE *inf = fopen(m_p->content_config_file.c_str(), "r");
+            if (inf)
+            {
+                char buf[1024];
+                while (fgets(buf, sizeof(buf)-1, inf))
+                {
+                    char *cp;
+                    cp = strchr(buf, '#');
+                    if (cp)
+                        *cp = '\0';
+                    cp = strchr(buf, '\n');
+                    if (cp)
+                        *cp = '\0';
+                    cp = strchr(buf, ':');
+                    if (cp)
+                    {
+                        char *cp1 = cp;
+                        while (cp1 != buf && cp1[-1] == ' ')
+                            cp1--;
+                        *cp1 = '\0';
+                        cp++;
+                        while (*cp == ' ')
+                            cp++;
+                        if (!strcmp(buf, "proxyhostname"))
+                            proxyhostname = cp; 
+                        if (!strcmp(buf, "sessiondir") && *cp)
+                        {
+                            if (cp[strlen(cp)-1] == '/')
+                                cp[strlen(cp)-1] = '\0';
+                            tmp_file = std::string(cp) + std::string("/cf.XXXXXX.p");
+                        }
+                    }
+                }
+                fclose(inf);
+            }
+            else
+            {
+                package.log("zoom", YLOG_WARN|YLOG_ERRNO,
+                            "unable to open content config %s",
+                            m_p->content_config_file.c_str());
+                *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
+                *addinfo = (char *)  odr_malloc(odr, 60 + tmp_file.length());
+                sprintf(*addinfo, "unable to open content config %s",
+                        m_p->content_config_file.c_str());
+                return false;
+            }
+        }
+
+        if (proxyhostname.length() == 0)
+        {
+            package.log("zoom", YLOG_WARN, "no proxyhostname");
+            return true;
+        }
+        if (tmp_file.length() == 0)
+        {
+            package.log("zoom", YLOG_WARN, "no tmp_file");
+            return true;
+        }
+
+        char *fname = xstrdup(tmp_file.c_str());
         char *xx = strstr(fname, "XXXXXX");
         if (!xx)
         {
-            xx = fname + strlen(fname);
-            strcat(fname, "XXXXXX");
+            package.log("zoom", YLOG_WARN, "bad tmp_file %s", tmp_file.c_str());
+            *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR;
+            *addinfo = (char *)  odr_malloc(odr, 60 + tmp_file.length());
+            sprintf(*addinfo, "bad format of content tmp_file: %s",
+                    tmp_file.c_str());
+            xfree(fname);
+            return false;
         }
         char tmp_char = xx[6];
         sprintf(xx, "%06d", ((unsigned) rand()) % 1000000);
+        if (legacy_format)
+            b->cproxy_host = std::string(xx) + "." + proxyhostname;
+        else
+            b->cproxy_host = proxyhostname + "/" + xx;
         xx[6] = tmp_char;
 
         FILE *file = fopen(fname, "w");
@@ -842,7 +934,6 @@ bool yf::Zoom::Frontend::create_content_session(mp::Package &package,
             xfree(fname);
             return false;
         }
-        b->content_session_id.assign(xx, 6);
         mp::wrbuf w;
         wrbuf_puts(w, "#content_proxy\n");
         wrbuf_printf(w, "connector: %s\n", b->sptr->contentConnector.c_str());
@@ -1409,11 +1500,12 @@ Z_Records *yf::Zoom::Frontend::get_records(Package &package,
         const char *xsl_parms[3];
         mp::wrbuf cproxy_host;
         
-        if (b->enable_cproxy && b->content_session_id.length())
+        if (b->enable_cproxy && b->cproxy_host.length())
         {
-            wrbuf_printf(cproxy_host, "\"%s.%s/\"",
-                         b->content_session_id.c_str(),
-                         m_p->content_proxy_server.c_str());
+            wrbuf_puts(cproxy_host, "\"");
+            wrbuf_puts(cproxy_host, b->cproxy_host.c_str());
+            wrbuf_puts(cproxy_host, "/\"");
+
             xsl_parms[0] = "cproxyhost";
             xsl_parms[1] = wrbuf_cstr(cproxy_host);
             xsl_parms[2] = 0;
index 3c48fc3..7012053 100644 (file)
@@ -7,7 +7,7 @@
 DEBUG=0   # 0 for release, 1 for debug
 
 # Metaproxy version
-VERSION=1.3.28
+VERSION=1.3.29
 
 # YAZ and YAZ++ directories
 YAZ_DIR=..\..\yaz
index 1b5f900..1599ce8 100644 (file)
@@ -62,6 +62,7 @@ filter_zoom =
     }*
   }?,
   element mp:contentProxy {
+    attribute config_file { xsd:string }?,
     attribute server { xsd:string }?,
     attribute tmp_file { xsd:string }?
   }?,