From ad783ccaf07fed369dcfee61146be61aed693d37 Mon Sep 17 00:00:00 2001 From: "roberto@precise64" Date: Fri, 24 Feb 2012 06:49:54 +0100 Subject: [PATCH] added script for external app loading --- contrib/loadapp.pl | 15 +++++++++++++++ plugins/psgi/uwsgi_plmodule.c | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 contrib/loadapp.pl diff --git a/contrib/loadapp.pl b/contrib/loadapp.pl new file mode 100644 index 00000000..f1dec5b7 --- /dev/null +++ b/contrib/loadapp.pl @@ -0,0 +1,15 @@ +use IO::Socket::INET; + +my $s = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => $ARGV[0]); + +my $mountpoint = $ARGV[1]; +my $app = $ARGV[2]; + +my $uwsgi_appid = pack('v', length('UWSGI_APPID')).'UWSGI_APPID'.pack('v', length($mountpoint)).$mountpoint; +my $uwsgi_script = pack('v', length('UWSGI_SCRIPT')).'UWSGI_SCRIPT'.pack('v', length($app)).$app; + +$s->send(pack('CvC', 5, length($uwsgi_appid.$uwsgi_script),0).$uwsgi_appid.$uwsgi_script); + +while((my $cnt = $s->recv(my $buf, 4096))> 0) { + print $buf; +} diff --git a/plugins/psgi/uwsgi_plmodule.c b/plugins/psgi/uwsgi_plmodule.c index 0e5cbccb..27481fe5 100644 --- a/plugins/psgi/uwsgi_plmodule.c +++ b/plugins/psgi/uwsgi_plmodule.c @@ -96,6 +96,8 @@ XS(XS_cache_set) { char *key, *val; STRLEN keylen; STRLEN vallen; + + if (uwsgi.cache_max_items == 0) goto clear; psgi_check_args(2); @@ -104,6 +106,7 @@ XS(XS_cache_set) { uwsgi_cache_set(key, (uint16_t) keylen, val, (uint64_t) vallen, 0, 0); +clear: XSRETURN_UNDEF; } @@ -113,6 +116,8 @@ XS(XS_cache_get) { char *key, *val; STRLEN keylen; uint64_t vallen; + + if (uwsgi.cache_max_items == 0) goto clear; psgi_check_args(1); @@ -121,6 +126,7 @@ XS(XS_cache_get) { val = uwsgi_cache_get(key, (uint16_t) keylen, &vallen); if (!val) +clear: XSRETURN_UNDEF; ST(0) = newSVpv(val, vallen);