xml parsing and pluginized getopt_long stabilization

This commit is contained in:
roberto@sirius
2010-10-21 11:45:49 +02:00
parent bfbca5bc96
commit 7041a9fa45
14 changed files with 144 additions and 183 deletions
+9 -9
View File
@@ -374,32 +374,32 @@ PyObject *uwsgi_dyn_loader(void *arg1) {
struct wsgi_request *wsgi_req = (struct wsgi_request *) arg1;
// MANAGE UWSGI_SCRIPT
if (wsgi_req->wsgi_script_len > 0) {
tmpstr = uwsgi_strncopy(wsgi_req->wsgi_script, wsgi_req->wsgi_script_len);
if (wsgi_req->script_len > 0) {
tmpstr = uwsgi_strncopy(wsgi_req->script, wsgi_req->script_len);
callable = uwsgi_uwsgi_loader((void *)tmpstr);
free(tmpstr);
}
// MANAGE UWSGI_MODULE
else if (wsgi_req->wsgi_module_len > 0) {
if (wsgi_req->wsgi_callable_len > 0) {
tmpstr = uwsgi_concat3n(wsgi_req->wsgi_module, wsgi_req->wsgi_module_len, ":", 1, wsgi_req->wsgi_callable, wsgi_req->wsgi_callable_len);
else if (wsgi_req->module_len > 0) {
if (wsgi_req->callable_len > 0) {
tmpstr = uwsgi_concat3n(wsgi_req->module, wsgi_req->module_len, ":", 1, wsgi_req->callable, wsgi_req->callable_len);
}
else {
tmpstr = uwsgi_strncopy(wsgi_req->wsgi_module, wsgi_req->wsgi_module_len);
tmpstr = uwsgi_strncopy(wsgi_req->module, wsgi_req->module_len);
}
callable = uwsgi_uwsgi_loader((void *)tmpstr);
free(tmpstr);
}
// MANAGE UWSGI_FILE
else if (wsgi_req->wsgi_file_len > 0) {
tmpstr = uwsgi_strncopy(wsgi_req->wsgi_file, wsgi_req->wsgi_file_len);
else if (wsgi_req->file_len > 0) {
tmpstr = uwsgi_strncopy(wsgi_req->file, wsgi_req->file_len);
callable = uwsgi_file_loader((void *)tmpstr);
free(tmpstr);
}
#ifdef UWSGI_PASTE
// MANAGE UWSGI_PASTE
else if (wsgi_req->wsgi_paste_len > 0) {
tmpstr = uwsgi_strncopy(wsgi_req->wsgi_paste, wsgi_req->wsgi_paste_len);
tmpstr = uwsgi_strncopy(wsgi_req->paste, wsgi_req->paste_len);
callable = uwsgi_paste_loader((void *)tmpstr);
free(tmpstr);
}
+31
View File
@@ -592,6 +592,36 @@ void uwsgi_python_init_thread() {
}
int uwsgi_python_xml(char *node, char *content) {
if (!strcmp("script", node)) {
return init_uwsgi_app(LOADER_UWSGI, content, uwsgi.wsgi_req, uwsgi.single_interpreter-1);
}
else if (!strcmp("file", node)) {
return init_uwsgi_app(LOADER_FILE, content, uwsgi.wsgi_req, uwsgi.single_interpreter-1);
}
else if (!strcmp("eval", node)) {
return init_uwsgi_app(LOADER_EVAL, content, uwsgi.wsgi_req, uwsgi.single_interpreter-1);
}
else if (!strcmp("module", node)) {
uwsgi.wsgi_req->module = content;
uwsgi.wsgi_req->module_len = strlen(content);
return 1;
}
else if (!strcmp("pyhome", node)) {
uwsgi.wsgi_req->pyhome = content;
uwsgi.wsgi_req->pyhome_len = strlen(content);
return 1;
}
else if (!strcmp("callable", node)) {
uwsgi.wsgi_req->callable = content;
uwsgi.wsgi_req->callable_len = strlen(content);
return init_uwsgi_app(LOADER_DYN, uwsgi.wsgi_req, uwsgi.wsgi_req, uwsgi.single_interpreter-1);
}
return 0;
}
struct uwsgi_plugin python_plugin = {
.name = "python",
@@ -605,6 +635,7 @@ struct uwsgi_plugin python_plugin = {
.init_apps = uwsgi_python_init_app,
.enable_threads = uwsgi_python_enable_threads,
.init_thread = uwsgi_python_init_thread,
.manage_xml = uwsgi_python_xml,
/*
.magic = uwsgi_python_magic,
.help = uwsgi_python_help,
-4
View File
@@ -12,9 +12,7 @@ PyObject *python_call(PyObject *callable, PyObject *args, int catch) {
PyObject *pyret;
uwsgi_log("CALLING %p %p\n", callable, args);
pyret = PyEval_CallObject(callable, args);
uwsgi_log("CALLED\n");
if (PyErr_Occurred()) {
if (!catch) {
@@ -28,8 +26,6 @@ PyObject *python_call(PyObject *callable, PyObject *args, int catch) {
}
#endif
uwsgi_log("called\n");
return pyret;
}
Binary file not shown.
+4 -11
View File
@@ -106,7 +106,6 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
return -1;
}
uwsgi_log("uno\n");
if (uwsgi.limit_post) {
if (wsgi_req->post_cl > uwsgi.limit_post) {
@@ -138,11 +137,11 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
if (wsgi_req->script_name_len > 1 || uwsgi.default_app < 0 || uwsgi.vhost) {
/* unavailable app for this SCRIPT_NAME */
wsgi_req->app_id = -1;
if (wsgi_req->wsgi_script_len > 0
|| wsgi_req->wsgi_module_len > 0
|| wsgi_req->wsgi_file_len > 0
if (wsgi_req->script_len > 0
|| wsgi_req->module_len > 0
|| wsgi_req->file_len > 0
#ifdef UWSGI_PASTE
|| wsgi_req->wsgi_paste_len > 0
|| wsgi_req->paste_len > 0
#endif
) {
// a bit of magic: 1-1 = 0 / 0-1 = -1
@@ -275,7 +274,6 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
uwsgi_log("OOOOOPS000\n");
if (uwsgi.post_buffering > 0 && wsgi_req->post_cl > (size_t) uwsgi.post_buffering) {
UWSGI_RELEASE_GIL
@@ -317,15 +315,12 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
wsgi_req->async_result = wi->request_subhandler(wsgi_req, wi);
uwsgi_log("fase2\n");
if (wsgi_req->async_result) {
UWSGI_RELEASE_GIL
while ( (*wi->response_subhandler)(wsgi_req) != UWSGI_OK) {
wsgi_req->switches++;
uwsgi_log("again...\n");
#ifdef UWSGI_ASYNC
if (uwsgi.async > 1) {
return UWSGI_AGAIN;
@@ -369,7 +364,6 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) {
close(tmp_stderr);
}
uwsgi_log("opps\n");
clear:
@@ -396,7 +390,6 @@ clear2:
void uwsgi_after_request_wsgi(struct wsgi_request *wsgi_req) {
uwsgi_log("LOGGING\n");
if (uwsgi.shared->options[UWSGI_OPTION_LOGGING]) {
log_request(wsgi_req);
-2
View File
@@ -28,8 +28,6 @@ PyObject *py_uwsgi_spit(PyObject * self, PyObject * args) {
}
*/
uwsgi_log("HEADERS !!!!\n");
head = PyTuple_GetItem(args, 0+shift);
if (!head) {
goto clear;
-2
View File
@@ -75,7 +75,6 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
PyDict_SetItemString(wsgi_req->async_environ, "wsgi.url_scheme", zero);
Py_DECREF(zero);
uwsgi_log("subhandler ok\n");
wsgi_req->async_app = wi->callable ;
@@ -98,7 +97,6 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_
PyTuple_SetItem(wsgi_req->async_args, 0, wsgi_req->async_environ);
uwsgi_log("subhandler2 ok %p %p %p\n", wsgi_req->async_app, wsgi_req->async_args, wsgi_req->async_environ );
return python_call(wsgi_req->async_app, wsgi_req->async_args, up.catch_exceptions);
}