Skip to content

Commit

Permalink
xmlconf fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto@sirius committed Aug 26, 2010
1 parent 47f7c09 commit 720da09
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion uwsgi.c
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions uwsgi.h
Expand Up @@ -678,6 +678,8 @@ struct uwsgi_server {
int ping_timeout;

char *callable;

int xml_round2;
};

struct uwsgi_cluster_node {
Expand Down
31 changes: 29 additions & 2 deletions xmlconf.c
Expand Up @@ -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 ;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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)
Expand All @@ -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;
}
Expand Down

0 comments on commit 720da09

Please sign in to comment.