diff --git a/buildconf/core.ini b/buildconf/core.ini index a9f8a57c..58aac109 100644 --- a/buildconf/core.ini +++ b/buildconf/core.ini @@ -1,30 +1,3 @@ [uwsgi] -xml = true -ini = true -yaml = true -snmp = true -sctp = false -erlang = false -spooler = true -embedded = true -udp = true -multicast = false -threading = true -sendfile = true -nagios = true -proxy = true -minterpreters = true -async = true -ugreen = true -http = true -evdis = false -ldap = false -routing = false -stackless = false -debug = false -unbit = false -xml_implementation = libxml2 -plugins = -bin_name = uwsgi -plugin_dir = . -embedded_plugins = +inherit = default +embedded_plugins = null diff --git a/plugins/psgi/uwsgi_plmodule.c b/plugins/psgi/uwsgi_plmodule.c index fd69ce74..64c4dea9 100644 --- a/plugins/psgi/uwsgi_plmodule.c +++ b/plugins/psgi/uwsgi_plmodule.c @@ -3,6 +3,7 @@ extern struct uwsgi_server uwsgi; #define psgi_xs(func) newXS("uwsgi::" #func, XS_##func, "uwsgi") +#define psgi_check_args(x) if (items < x) Perl_croak(aTHX_ "Usage: uwsgi::%s takes %d arguments", __FUNCTION__ + 3, x) XS(XS_reload) { dXSARGS; @@ -16,8 +17,82 @@ XS(XS_reload) { XSRETURN_YES; } +XS(XS_cache_set) { + dXSARGS; + + char *key, *val; + STRLEN keylen; + STRLEN vallen; + + psgi_check_args(2); + + key = SvPV(ST(0), keylen); + val = SvPV(ST(1), vallen); + + uwsgi_cache_set(key, (uint16_t) keylen, val, (uint16_t) vallen, 0); + + XSRETURN_UNDEF; +} + +XS(XS_cache_get) { + dXSARGS; + + char *key, *val; + STRLEN keylen; + uint16_t vallen; + + psgi_check_args(1); + + key = SvPV(ST(0), keylen); + + val = uwsgi_cache_get(key, (uint16_t) keylen, &vallen); + + if (!val) + XSRETURN_UNDEF; + + ST(0) = newSVpv(val, vallen); + sv_2mortal(ST(0)); + + XSRETURN(1); + +} + +XS(XS_call) { + + dXSARGS; + + char buffer[0xffff]; + char *func; + uint16_t size = 0; + int i; + char *argv[0xff]; + + psgi_check_args(1); + + func = SvPV_nolen(ST(0)); + + for(i=0;i<(items-1);i++) { + argv[i] = SvPV_nolen(ST(i+1)); + } + + size = uwsgi_rpc(func, items-1, argv, buffer); + + if (size > 0) { + ST(0) = newSVpv(buffer, size); + sv_2mortal(ST(0)); + + XSRETURN(1); + } + + XSRETURN_UNDEF; +} + + void init_perl_embedded_module() { psgi_xs(reload); + psgi_xs(cache_set); + psgi_xs(cache_get); + psgi_xs(call); } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 514d3d84..e75d7c31 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -814,6 +814,10 @@ uint16_t uwsgi_python_rpc(void * func, uint8_t argc, char **argv, char *buffer) } } + if (PyErr_Occurred()) + PyErr_Print(); + + return 0; } diff --git a/test.psgi b/test.psgi index e4825520..42ab3bcc 100644 --- a/test.psgi +++ b/test.psgi @@ -1,12 +1,15 @@ use strict; use warnings; +print "rpc value = ".uwsgi::call('hello')."\n"; + my $app = sub { my $env = shift; - #uwsgi::reload; + uwsgi::cache_set("key1", "val1"); + print uwsgi::call('hello'); return [ '200', [ 'Content-Type' => 'text/plain' ], - [ "Hello World\r\n", $env->{'REQUEST_URI'} ], + [ "Hello World\r\n", $env->{'REQUEST_URI'}, uwsgi::cache_get('key1'), uwsgi::call('hello') ], ]; }; diff --git a/uwsgi.c b/uwsgi.c index b3373cb5..47efe1b2 100644 --- a/uwsgi.c +++ b/uwsgi.c @@ -1555,13 +1555,21 @@ uwsgi.shared->hooks[UWSGI_MODIFIER_PING] = uwsgi_request_ping; //100 // eventually remap plugins if (uwsgi.remap_modifier) { char *map = strtok(uwsgi.remap_modifier, ","); + struct uwsgi_plugin *up_tmp; while (map != NULL) { char *colon = strchr(map, ':'); if (colon) { colon[0] = 0; int rm_src = atoi(map); int rm_dst = atoi(colon+1); + up_tmp = uwsgi.p[rm_dst] ; uwsgi.p[rm_dst] = uwsgi.p[rm_src]; + uwsgi.p[rm_src] = up_tmp ; + // fix rpc + for(i=0;irpc_count;i++) { + if (uwsgi.shared->rpc_table[i].modifier1 == rm_src) uwsgi.shared->rpc_table[i].modifier1 = rm_dst; + else if (uwsgi.shared->rpc_table[i].modifier1 == rm_dst) uwsgi.shared->rpc_table[i].modifier1 = rm_src; + } } map = strtok(NULL, ","); } diff --git a/uwsgiconfig.py b/uwsgiconfig.py index f2e1fc03..c1efa712 100644 --- a/uwsgiconfig.py +++ b/uwsgiconfig.py @@ -173,6 +173,8 @@ class uConf(object): self.set(opt, iconfig.get('uwsgi', opt)) elif self.get(opt).startswith('+'): self.set(opt, iconfig.get('uwsgi', opt) + self.get(opt)[1:]) + elif self.get(opt) == 'null': + self.config.remove_option('uwsgi', opt) def set(self, key, value):