Change repr of service XML
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 29 May 2013 20:25:14 +0000 (22:25 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 29 May 2013 20:25:14 +0000 (22:25 +0200)
from XML nodes to serialized (string). This reduces memory overhead
for service structure considerably.

src/http_command.c
src/pazpar2_config.c
src/pazpar2_config.h
test/test_url_19.res

index b753ff0..56e1f63 100644 (file)
@@ -658,24 +658,12 @@ static void session_status(struct http_channel *c, struct http_session *s)
 static void cmd_service(struct http_channel *c)
 {
     struct http_session *s = locate_session(c);
-    xmlNode *xml_node;
     if (!s)
         return;
 
     response_open_command(c, 0);
-    xml_node = s->psession->service->xml_node;
-    if (xml_node)
-    {
-        xmlNode *tmp = xmlCopyNode(xml_node, 1);
-        xmlBufferPtr buf = xmlBufferCreate();
-
-        xmlNodeDump(buf, tmp->doc, tmp, 0, 0);
-
-        wrbuf_write(c->wrbuf, (const char *) buf->content, buf->use);
-        xmlBufferFree(buf);
-        xmlFreeNode(tmp);
-    }
-
+    if (s->psession->service->xml_node)
+        wrbuf_puts(c->wrbuf, s->psession->service->xml_node);
     response_close(c, 0);
     release_session(c, s);
 }
index 49a73d7..167424d 100644 (file)
@@ -150,9 +150,7 @@ struct conf_service *service_init(struct conf_server *server,
         service->sortkeys
             = nmem_malloc(nmem,
                           sizeof(struct conf_sortkey) * service->num_sortkeys);
-
     service->xml_node = 0;
-
     return service;
 }
 
@@ -273,8 +271,6 @@ void service_destroy(struct conf_service *service)
         if (!pazpar2_decref(&service->ref_count, service->mutex))
         {
             service_xslt_destroy(service);
-            if (service->xml_node)
-                xmlFreeNode(service->xml_node);
             pp2_charset_fact_destroy(service->charsets);
             ccl_qual_rm(&service->ccl_bibset);
             yaz_mutex_destroy(&service->mutex);
@@ -746,7 +742,14 @@ static struct conf_service *service_create_static(struct conf_server *server,
             }
         }
     }
-    service->xml_node = xmlCopyNode(node, 1);
+
+    {
+        xmlBufferPtr buf = xmlBufferCreate();
+        xmlNodeDump(buf, node->doc, node, 0, 0);
+        service->xml_node =
+            nmem_strdupn(service->nmem, (const char *) buf->content, buf->use);
+        xmlBufferFree(buf);
+    }
     return service;
 }
 
index 4324fa1..ee195b9 100644 (file)
@@ -134,7 +134,7 @@ struct conf_service
     CCL_bibset ccl_bibset;
     struct database *databases;
     struct conf_server *server;
-    xmlNode *xml_node;
+    char *xml_node;
 };
 
 int conf_service_metadata_field_id(struct conf_service *service, const char * name);
index c5c659c..b4efe0d 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<service xmlns="http://www.indexdata.com/pazpar2/1.0">
+<service>
       <icu_chain id="relevance" locale="en">
        <transform rule="[:Control:] Any-Remove"/>
        <tokenize rule="l"/>