From 720da096317e4961a93305020d7a68ce5dfb4a7a Mon Sep 17 00:00:00 2001 From: "roberto@sirius" Date: Thu, 26 Aug 2010 15:33:25 +0200 Subject: [PATCH] xmlconf fixes --- uwsgi.c | 2 +- uwsgi.h | 2 ++ xmlconf.c | 31 +++++++++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/uwsgi.c b/uwsgi.c index 08f452cac5..67d83a29ae 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -1067,7 +1067,7 @@ int main(int argc, char *argv[], char *envp[]) { // parse xml anyway #ifdef UWSGI_XML - if (uwsgi.xml_config != NULL) { + if (uwsgi.xml_round2 && uwsgi.xml_config != NULL) { uwsgi_xml_config(uwsgi.wsgi_req, NULL); } #endif diff --git a/uwsgi.h b/uwsgi.h index 6cda24de41..58c952b1f6 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -678,6 +678,8 @@ struct uwsgi_server { int ping_timeout; char *callable; + + int xml_round2; }; struct uwsgi_cluster_node { diff --git a/xmlconf.c b/xmlconf.c index 5c927ed62f..c0ab1ddfe2 100644 --- a/xmlconf.c +++ b/xmlconf.c @@ -23,6 +23,8 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options char *colon ; + char *xml_id ; + colon = strchr(uwsgi.xml_config, ':'); if (colon) { colon[0] = 0 ; @@ -54,8 +56,10 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options element = NULL ; if (node->type == XML_ELEMENT_NODE) { if (!strcmp((char *) node->name, "uwsgi")) { - if (colon) { - if (strcmp(colon, (char *) xmlGetProp(node, (const xmlChar *) "id")) ) { + xml_id = (char *) xmlGetProp(node, (const xmlChar *) "id"); + + if (colon && xml_id) { + if ( strcmp(colon, xml_id) ) { continue; } } @@ -76,6 +80,22 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options // first check for options for (node = element->children; node; node = node->next) { if (node->type == XML_ELEMENT_NODE) { + + if (!strcmp((char *) node->name, "app")) { + uwsgi.xml_round2 = 1 ; + continue; + } + +#ifdef UWSGI_ROUTING + if (!strcmp((char *) node->name, "route")) { + uwsgi.xml_round2 = 1 ; + continue; + } + if (!strcmp((char *) node->name, "routing")) { + uwsgi.xml_round2 = 1 ; + continue; + } +#endif lopt = long_options; while ((aopt = lopt)) { if (!aopt->name) @@ -100,6 +120,13 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options } } + xml_id = (char *) xmlGetProp(node, (const xmlChar *) "id") ; + if (colon && xml_id) { + if (strcmp(colon, xml_id)) { + goto next; + } + } + if (aopt->flag) { *aopt->flag = aopt->val; }