From b7edaa68c8b3bf75d331cb7826e3aae47c2514ee Mon Sep 17 00:00:00 2001 From: "roberto@voldemort" Date: Sat, 26 Jun 2010 22:37:46 +0200 Subject: [PATCH] various fixes from 0.9.5.2 --- ChangeLog | 16 +++++++- debian/DEBIAN/control | 6 --- lighttpd/mod_uwsgi.c | 2 +- logging.c | 1 - nginx/ngx_http_uwsgi_module.c | 4 +- plugins.c | 2 - plugins/lua/lua_plugin.c | 3 +- pyutils.c | 49 +++++++++++++++++++++- sendfile.c | 2 +- socket.c | 19 ++++++--- utils.c | 6 +-- uwsgi.c | 77 +++++++++++++---------------------- uwsgi.h | 19 ++++++++- uwsgiconfig.py | 26 +++++++++--- wsgi_handlers.c | 5 +++ xmlconf.c | 20 +++++---- 16 files changed, 168 insertions(+), 89 deletions(-) delete mode 100644 debian/DEBIAN/control diff --git a/ChangeLog b/ChangeLog index fce635b8..4bbcb21b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +*** june 2010 *** + + * 0.9.5.2 [20100626] * + +- fixed a request parsing bug +- applied debian fixes +- fixed multiple interpreter sys.argv +- improved --chmod-socket +- fixed uid 0 SIGHUP +- updated nginx and apache modules +- updated PSGI, lua and example plugin +- fixed --pyargv with python 3.x +- improved plugin build system + *** may 2010 *** * 0.9.5.1 [20100519] * @@ -24,7 +38,7 @@ - logging via udp - improved spooler for cron-like apps - async support -- green thread platform (uGreen) on top of teh async mode +- green thread platform (uGreen) on top of the async mode - transparent Erlang integration - embedded snmp agent - nagios mode diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control deleted file mode 100644 index 2281e25f..00000000 --- a/debian/DEBIAN/control +++ /dev/null @@ -1,6 +0,0 @@ -Package: uwsgi -Version: 0.9.5 -Maintainer: Unbit -Description: Fast, developer-friendly wsgi server -Architecture: all -Depends: python, libxml2 diff --git a/lighttpd/mod_uwsgi.c b/lighttpd/mod_uwsgi.c index f5bc6b16..ce6794aa 100644 --- a/lighttpd/mod_uwsgi.c +++ b/lighttpd/mod_uwsgi.c @@ -38,7 +38,7 @@ #ifdef __linux__ #include #elif __sun__ -#elif __apple__ +#elif __APPLE__ #include #else #include diff --git a/logging.c b/logging.c index 21c97dbe..a145e133 100644 --- a/logging.c +++ b/logging.c @@ -45,7 +45,6 @@ void log_request(struct wsgi_request *wsgi_req) { app_req = wi->requests; } } - via = msg2; if (wsgi_req->sendfile_fd > -1) { via = msg1; diff --git a/nginx/ngx_http_uwsgi_module.c b/nginx/ngx_http_uwsgi_module.c index e3946612..c18691ad 100644 --- a/nginx/ngx_http_uwsgi_module.c +++ b/nginx/ngx_http_uwsgi_module.c @@ -35,7 +35,9 @@ #include #include -#define NGX_HTTP_UWSGI_TEMP_PATH "uwsgi_temp" +#ifndef NGX_HTTP_UWSGI_TEMP_PATH + #define NGX_HTTP_UWSGI_TEMP_PATH "uwsgi_temp" +#endif typedef struct { ngx_http_upstream_conf_t upstream; diff --git a/plugins.c b/plugins.c index 7900f1a2..15eddd86 100644 --- a/plugins.c +++ b/plugins.c @@ -2,8 +2,6 @@ void embed_plugins(struct uwsgi_server *uwsgi) { - int ret ; - #ifdef UWSGI_EMBED_PLUGIN_PSGI if (uwsgi->plugin_arg_psgi) ret = uwsgi_load_plugin(uwsgi, 5, "psgi_plugin.so", uwsgi->plugin_arg_psgi, 0); diff --git a/plugins/lua/lua_plugin.c b/plugins/lua/lua_plugin.c index bbc865e1..61a3a70e 100644 --- a/plugins/lua/lua_plugin.c +++ b/plugins/lua/lua_plugin.c @@ -104,8 +104,7 @@ int uwsgi_request(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req) { } // put function in the stack - lua_pushvalue(ulua.L, -1); - lua_getfield(ulua.L, -1, "run"); + lua_getfield(ulua.L, LUA_GLOBALSINDEX, "run"); // put cgi vars in the stack lua_newtable(ulua.L); diff --git a/pyutils.c b/pyutils.c index fc4e50b1..9292cd3c 100644 --- a/pyutils.c +++ b/pyutils.c @@ -167,7 +167,9 @@ PyObject *python_call(PyObject *callable, PyObject *args) { } #ifdef UWSGI_DEBUG - uwsgi_debug("called %p %p %d\n", callable, args, pyret ? pyret->ob_refcnt : NULL); + if (pyret) { + uwsgi_debug("called %p %p %d\n", callable, args, pyret->ob_refcnt); + } #endif @@ -192,3 +194,48 @@ int uwsgi_python_call(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req, return UWSGI_OK; } + +void init_pyargv(struct uwsgi_server *uwsgi) { + +#ifdef PYTHREE + wchar_t pname[6]; + mbstowcs(pname, "uwsgi", 6); + uwsgi->py_argv[0] = pname; +#else + uwsgi->py_argv[0] = "uwsgi"; +#endif + + if (uwsgi->pyargv != NULL && !uwsgi->pyargc) { + uwsgi->pyargc++; +#ifdef PYTHREE + wchar_t *wcargv = malloc( sizeof( wchar_t ) * (strlen(uwsgi->pyargv)+1)); + if (!wcargv) { + uwsgi_error("malloc()"); + exit(1); + } + memset(wcargv, 0, sizeof( wchar_t ) * (strlen(uwsgi->pyargv)+1)); +#endif + char *ap; +#ifdef __sun__ + // FIX THIS !!! + ap = strtok(uwsgi->pyargv, " "); + while ((ap = strtok(NULL, " ")) != NULL) { +#else + while ((ap = strsep(&uwsgi->pyargv, " \t")) != NULL) { +#endif + if (*ap != '\0') { +#ifdef PYTHREE + mbstowcs( wcargv + strlen(ap), ap, strlen(ap)); + uwsgi->py_argv[uwsgi->pyargc] = wcargv + strlen(ap); +#else + uwsgi->py_argv[uwsgi->pyargc] = ap; +#endif + uwsgi->pyargc++; + } + if (uwsgi->pyargc + 1 > MAX_PYARGV) + break; + } + } + + PySys_SetArgv(uwsgi->pyargc, uwsgi->py_argv); +} diff --git a/sendfile.c b/sendfile.c index ffd05d92..a8d31182 100644 --- a/sendfile.c +++ b/sendfile.c @@ -66,7 +66,7 @@ ssize_t uwsgi_sendfile(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req } return sf_len; -#elif __APPLE__ +#elif defined(__APPLE__) off_t sf_len = wsgi_req->sendfile_fd_size ; if (uwsgi->async > 1) { diff --git a/socket.c b/socket.c index bda134c8..0384825c 100644 --- a/socket.c +++ b/socket.c @@ -52,12 +52,21 @@ int bind_to_unix(char *socket_name, int listen_queue, int chmod_socket, int abst // chmod unix socket for lazy users if (chmod_socket == 1 && abstract_socket == 0) { - uwsgi_log( "chmod() socket to 666 for lazy and brave users\n"); - if (chmod(socket_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) != 0) { - uwsgi_error("chmod()"); + if (uwsgi.chmod_socket_value) { + if (chmod(socket_name, uwsgi.chmod_socket_value) != 0) { + uwsgi_error("chmod()"); + } + } + else { + uwsgi_log( "chmod() socket to 666 for lazy and brave users\n"); + if (chmod(socket_name, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) != 0) { + uwsgi_error("chmod()"); + } } } + free(uws_addr); + return serverfd; } @@ -230,7 +239,6 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { int serverfd; struct sockaddr_in uws_addr; int reuse = 1; - int i, ret; tcp_port[0] = 0; memset(&uws_addr, 0, sizeof(struct sockaddr_in)); @@ -263,7 +271,8 @@ int bind_to_tcp(char *socket_name, int listen_queue, char *tcp_port) { if (setsockopt(serverfd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], sizeof(int))) { uwsgi_error("setsockopt()"); } -#elif defined(__apple__) || defined(__freebsd__) +// OSX has no SO_ACCEPTFILTER !!! +#elif defined(__freebsd__) struct accept_filter_arg afa; strcpy(afa.af_name, "dataready"); afa.af_arg[0] = 0; diff --git a/utils.c b/utils.c index d2c108e2..d606224c 100644 --- a/utils.c +++ b/utils.c @@ -255,15 +255,15 @@ void uwsgi_as_root() { } } else { - if (uwsgi.chroot) { + if (uwsgi.chroot && !uwsgi.is_a_reload) { uwsgi_log("cannot chroot() as non-root user\n"); exit(1); } - if (uwsgi.gid) { + if (uwsgi.gid && getgid() != uwsgi.gid) { uwsgi_log("cannot setgid() as non-root user\n"); exit(1); } - if (uwsgi.uid) { + if (uwsgi.uid && getuid() != uwsgi.uid) { uwsgi_log("cannot setuid() as non-root user\n"); exit(1); } diff --git a/uwsgi.c b/uwsgi.c index a66cdee0..b3446e73 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -203,13 +203,6 @@ int main(int argc, char *argv[], char *envp[]) { uint64_t master_cycles = 0; struct timeval check_interval = {.tv_sec = 1,.tv_usec = 0 }; -#ifdef PYTHREE - wchar_t *pyargv[MAX_PYARGV]; -#else - char *pyargv[MAX_PYARGV]; -#endif - int pyargc = 1; - int i; int rlen; @@ -305,7 +298,7 @@ int main(int argc, char *argv[], char *envp[]) { {"memory-report", no_argument, 0, 'm'}, {"cgi-mode", no_argument, 0, 'c'}, {"abstract-socket", no_argument, 0, 'a'}, - {"chmod-socket", no_argument, 0, 'C'}, + {"chmod-socket", optional_argument , 0, 'C'}, #ifdef UWSGI_THREADING {"enable-threads", no_argument, 0, 'T'}, #endif @@ -656,47 +649,7 @@ int main(int argc, char *argv[], char *envp[]) { Py_Initialize(); - -#ifdef PYTHREE - mbstowcs(pname, "uwsgi", 6); - pyargv[0] = pname; -#else - pyargv[0] = "uwsgi"; -#endif - - if (uwsgi.pyargv != NULL) { -#ifdef PYTHREE - wchar_t *wcargv = malloc( sizeof( wchar_t ) * strlen(uwsgi.pyargv)); - if (!wcargv) { - uwsgi_error("malloc()"); - exit(1); - } - wchar_t *wa; -#endif - char *ap; -#ifdef __sun__ - // FIX THIS !!! - ap = strtok(uwsgi.pyargv, " "); - while ((ap = strtok(NULL, " ")) != NULL) { -#else - while ((ap = strsep(&uwsgi.pyargv, " \t")) != NULL) { -#endif - if (*ap != '\0') { -#ifdef PYTHREE - wa = (wchar_t *) ( (ap-uwsgi.pyargv) * sizeof(wchar_t) ); - mbstowcs(wa, ap, strlen(ap)); - pyargv[pyargc] = wa; -#else - pyargv[pyargc] = ap; -#endif - pyargc++; - } - if (pyargc + 1 > MAX_PYARGV) - break; - } - } - - PySys_SetArgv(pyargc, pyargv); + init_pyargv(&uwsgi); if (uwsgi.vhost) { uwsgi_log("VirtualHosting mode enabled.\n"); @@ -1663,7 +1616,11 @@ void init_uwsgi_vars() { if (snprintf(venv_version, 15, "/lib/python%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION) == -1) { return ; } +#ifdef PYTHREE + venv_path = PyString_Concat( venv_path, PyString_FromString(venv_version) ); +#else PyString_Concat( &venv_path, PyString_FromString(venv_version) ); +#endif if ( PyList_Insert(pypath, 0, venv_path) ) { PyErr_Print(); @@ -1747,8 +1704,13 @@ int init_uwsgi_app(PyObject * force_wsgi_dict, PyObject * my_callable) { if (uwsgi.vhost) { zero = PyString_FromStringAndSize(uwsgi.wsgi_req->host, uwsgi.wsgi_req->host_len); +#ifdef PYTHREE + zero = PyString_Concat(zero, PyString_FromString("|")); + zero = PyString_Concat(zero, PyString_FromStringAndSize(uwsgi.wsgi_req->script_name, uwsgi.wsgi_req->script_name_len)); +#else PyString_Concat(&zero, PyString_FromString("|")); PyString_Concat(&zero, PyString_FromStringAndSize(uwsgi.wsgi_req->script_name, uwsgi.wsgi_req->script_name_len)); +#endif } else { zero = PyString_FromStringAndSize(uwsgi.wsgi_req->script_name, uwsgi.wsgi_req->script_name_len); @@ -1776,6 +1738,7 @@ int init_uwsgi_app(PyObject * force_wsgi_dict, PyObject * my_callable) { exit(1); } PyThreadState_Swap(wi->interpreter); + init_pyargv(&uwsgi); #ifdef UWSGI_EMBEDDED // we need to inizialize an embedded module for every interpreter @@ -2778,6 +2741,22 @@ void manage_opt(int i, char *optarg) { break; case 'C': uwsgi.chmod_socket = 1; + if (optarg) { + if (strlen(optarg) != 3) { + uwsgi_log("invalid chmod value: %s\n", optarg); + exit(1); + } + for(i=0;i<3;i++) { + if (optarg[i] < '0' || optarg[i] > '7') { + uwsgi_log("invalid chmod value: %s\n", optarg); + exit(1); + } + } + + uwsgi.chmod_socket_value = (uwsgi.chmod_socket_value << 3) + (optarg[0] - '0'); + uwsgi.chmod_socket_value = (uwsgi.chmod_socket_value << 3) + (optarg[1] - '0'); + uwsgi.chmod_socket_value = (uwsgi.chmod_socket_value << 3) + (optarg[2] - '0'); + } break; #endif case 'M': diff --git a/uwsgi.h b/uwsgi.h index 30be1058..500e8478 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -49,6 +49,10 @@ #include +#ifdef __APPLE__ +#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 +#endif + #include #include @@ -113,7 +117,7 @@ #endif /* this value are taken from nginx */ -#if defined(__apple__) || defined(__freebsd__) +#if defined(__APPLE__) || defined(__freebsd__) #define UWSGI_LISTEN_QUEUE -1 #else #define UWSGI_LISTEN_QUEUE 511 @@ -191,7 +195,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); #ifdef _BIG_ENDIAN #define __BIG_ENDIAN__ 1 #endif -#elif __apple__ +#elif __APPLE__ #include #else #include @@ -236,6 +240,7 @@ PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); #define PyString_FromFormat PyUnicode_FromFormat #define PyString_FromString PyUnicode_FromString #define PyString_Size PyUnicode_GET_DATA_SIZE +#define PyString_Concat PyUnicode_Concat #define PyString_AsString (char *) PyUnicode_AS_UNICODE #define PyFile_FromFile(A,B,C,D) PyFile_FromFd(fileno((A)), (B), (C), -1, NULL, NULL, NULL, 0) #endif @@ -553,6 +558,7 @@ struct uwsgi_server { #ifndef UNBIT int abstract_socket; int chmod_socket; + mode_t chmod_socket_value; int listen_queue; #ifdef UWSGI_XML @@ -564,6 +570,13 @@ struct uwsgi_server { char *python_path[64]; int python_path_cnt; char *pyargv; + + int pyargc; +#ifdef PYTHREE + wchar_t *py_argv[MAX_PYARGV]; +#else + char *py_argv[MAX_PYARGV]; +#endif #endif #ifdef UWSGI_ROUTING @@ -1011,3 +1024,5 @@ void check_route(struct uwsgi_server *, struct wsgi_request *); void uwsgi_route_action_uwsgi(struct uwsgi_server *, struct wsgi_request *, struct uwsgi_route *); void uwsgi_route_action_wsgi(struct uwsgi_server *, struct wsgi_request *, struct uwsgi_route *); #endif + +void init_pyargv(struct uwsgi_server *); diff --git a/uwsgiconfig.py b/uwsgiconfig.py index 8199bede..f53448da 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -19,7 +19,7 @@ ASYNC=True UGREEN=True EVDIS=True WSGI2=True -ROUTING=True +ROUTING=False STACKLESS=False #PLUGINS = ['psgi'] PLUGINS = [] @@ -64,7 +64,7 @@ gcc_list = ['utils', 'pyutils', 'protocol', 'socket', 'logging', 'wsgi_handlers' # large file support try: - cflags = ['-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() + cflags = ['-Wall', '-Werror', '-D_LARGEFILE_SOURCE', '-D_FILE_OFFSET_BITS=64'] + os.environ.get("CFLAGS", "").split() except: print("You need python headers to build uWSGI.") sys.exit(1) @@ -72,6 +72,9 @@ except: cflags = cflags + ['-I' + sysconfig.get_python_inc(), '-I' + sysconfig.get_python_inc(plat_specific=True) ] ldflags = os.environ.get("LDFLAGS", "").split() libs = ['-lpthread', '-rdynamic'] + sysconfig.get_config_var('LIBS').split() + sysconfig.get_config_var('SYSLIBS').split() +if sysconfig.get_config_var('LIBPL'): + libs.append('-L' + sysconfig.get_config_var('LIBPL')) + if USWALLOW: cflags = cflags + sysconfig.get_config_var('LLVM_CXXFLAGS').split() @@ -220,7 +223,20 @@ def parse_vars(): depends_on("ROUTING", ['WSGI2', 'XML']) cflags.append("-DUWSGI_ROUTING") gcc_list.append('routing') - libs.append('-lpcre') + pcreconf = spcall("pcre-config --cflags") + if pcreconf is None: + print ("*** Unable to locate pcre-config. The uWSGI build has been interrupted. You have to install pcre.") + sys.exit(1) + else: + cflags.append(pcreconf) + + pcreconf = spcall("pcre-config --libs") + if pcreconf is None: + print ("*** Unable to locate pcre-config. The uWSGI build has been interrupted. You have to install pcre.") + sys.exit(1) + else: + libs.append(pcreconf) + if EVDIS: cflags.append("-DUWSGI_EVDIS") @@ -316,11 +332,9 @@ def build_plugin(path): import uwsgiplugin as up p_cflags = cflags[:] - p_libs = libs[:] p_ldflags = ldflags[:] p_cflags.append(up.CFLAGS) - p_libs.append(up.LDFLAGS) p_cflags.insert(0, '-I.') @@ -332,7 +346,7 @@ def build_plugin(path): if uwsgi_os == 'Darwin': shared_flag = '-dynamiclib -undefined dynamic_lookup' - gccline = "%s -fPIC %s -o %s.so %s %s %s.c %s" % (GCC, shared_flag, plugin_dest, ' '.join(p_cflags), ' '.join(p_ldflags), plugin_base, ' '.join(p_libs)) + gccline = "%s -fPIC %s -o %s.so %s %s %s.c" % (GCC, shared_flag, plugin_dest, ' '.join(p_cflags), ' '.join(p_ldflags), plugin_base ) print(gccline) ret = os.system(gccline) diff --git a/wsgi_handlers.c b/wsgi_handlers.c index e0064007..c793d889 100644 --- a/wsgi_handlers.c +++ b/wsgi_handlers.c @@ -126,8 +126,13 @@ int uwsgi_request_wsgi(struct uwsgi_server *uwsgi, struct wsgi_request *wsgi_req if (wsgi_req->script_name_len > 0) { if (uwsgi->vhost) { zero = PyString_FromStringAndSize(wsgi_req->host, wsgi_req->host_len); +#ifdef PYTHREE + zero = PyString_Concat(zero, PyString_FromString("|")); + zero = PyString_Concat(zero, PyString_FromStringAndSize(wsgi_req->script_name, wsgi_req->script_name_len)); +#else PyString_Concat(&zero, PyString_FromString("|")); PyString_Concat(&zero, PyString_FromStringAndSize(wsgi_req->script_name, wsgi_req->script_name_len)); +#endif } else { zero = PyString_FromStringAndSize(wsgi_req->script_name, wsgi_req->script_name_len); diff --git a/xmlconf.c b/xmlconf.c index d158b474..0714c56b 100644 --- a/xmlconf.c +++ b/xmlconf.c @@ -116,8 +116,8 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options } #ifdef UWSGI_ROUTING else if (!strcmp((char *) node->name, "routing")) { - char *default_route_mountpoint = NULL; - char *default_route_callbase = NULL ; + unsigned char *default_route_mountpoint = NULL; + unsigned char *default_route_callbase = NULL ; xmlChar *tmp_val; int default_route_modifier1 = 0; int default_route_modifier2 = 0; @@ -129,12 +129,12 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options tmp_val = xmlGetProp(node, (const xmlChar *) "modifier1"); if (tmp_val) { - default_route_modifier1 = atoi(tmp_val); + default_route_modifier1 = atoi( (char *)tmp_val); } tmp_val = xmlGetProp(node, (const xmlChar *) "modifier2"); if (tmp_val) { - default_route_modifier2 = atoi(tmp_val); + default_route_modifier2 = atoi( (char *) tmp_val); } @@ -145,13 +145,13 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options uwsgi_log( "no route callable defined. skip.\n"); continue; } - uwsgi.routes[uwsgi.nroutes].mountpoint = default_route_mountpoint; - uwsgi.routes[uwsgi.nroutes].callbase = default_route_callbase; + uwsgi.routes[uwsgi.nroutes].mountpoint = (char *) default_route_mountpoint; + uwsgi.routes[uwsgi.nroutes].callbase = (char *) default_route_callbase; uwsgi.routes[uwsgi.nroutes].modifier1 = default_route_modifier1; uwsgi.routes[uwsgi.nroutes].modifier2 = default_route_modifier2; // TODO check for action uwsgi.routes[uwsgi.nroutes].action = NULL; - uwsgi.routes[uwsgi.nroutes].call = node2->children->content; + uwsgi.routes[uwsgi.nroutes].call = (char *) node2->children->content; if (uwsgi.routes[uwsgi.nroutes].call == NULL) { uwsgi_log( "no route callable defined. skip.\n"); continue; @@ -163,7 +163,7 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options continue; } - uwsgi.routes[uwsgi.nroutes].pattern = pcre_compile(tmp_val, 0, &errstr, &erroff, NULL); + uwsgi.routes[uwsgi.nroutes].pattern = pcre_compile( (char *) tmp_val, 0, &errstr, &erroff, NULL); uwsgi.routes[uwsgi.nroutes].pattern_extra = pcre_study(uwsgi.routes[uwsgi.nroutes].pattern, 0, &errstr); @@ -184,7 +184,11 @@ void uwsgi_xml_config(struct wsgi_request *wsgi_req, struct option *long_options } /* We cannot free xml resources on the first round (and with routing enabled) as the string pointer must be valid for all the server lifecycle */ +#ifdef UWSGI_ROUTING if (!long_options && !uwsgi.routing) { +#else + if (!long_options) { +#endif xmlFreeDoc (doc); xmlCleanupParser (); }