From: Adam Dickmeiss Date: Wed, 29 May 2013 20:25:14 +0000 (+0200) Subject: Change repr of service XML X-Git-Tag: v1.6.32~8 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=2185d73f6344aae67a124f1bc2a2e5695003cbd6;p=pazpar2-moved-to-github.git Change repr of service XML from XML nodes to serialized (string). This reduces memory overhead for service structure considerably. --- diff --git a/src/http_command.c b/src/http_command.c index b753ff0..56e1f63 100644 --- a/src/http_command.c +++ b/src/http_command.c @@ -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); } diff --git a/src/pazpar2_config.c b/src/pazpar2_config.c index 49a73d7..167424d 100644 --- a/src/pazpar2_config.c +++ b/src/pazpar2_config.c @@ -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; } diff --git a/src/pazpar2_config.h b/src/pazpar2_config.h index 4324fa1..ee195b9 100644 --- a/src/pazpar2_config.h +++ b/src/pazpar2_config.h @@ -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); diff --git a/test/test_url_19.res b/test/test_url_19.res index c5c659c..b4efe0d 100644 --- a/test/test_url_19.res +++ b/test/test_url_19.res @@ -1,5 +1,5 @@ - +