From f2e01428b6de0b7c691a9f0756ee2a06e654fe30 Mon Sep 17 00:00:00 2001 From: Unbit Date: Fri, 2 Mar 2018 09:18:46 +0100 Subject: [PATCH] added --dynamic-apps --- core/init.c | 2 ++ core/protocol.c | 10 +++++----- core/uwsgi.c | 1 + uwsgi.h | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/init.c b/core/init.c index b0660c8fc4..0c3178a3d9 100644 --- a/core/init.c +++ b/core/init.c @@ -95,6 +95,8 @@ void uwsgi_init_default() { uwsgi.cores = 1; uwsgi.threads = 1; + uwsgi.need_app = 1; + // default max number of rpc slot uwsgi.rpc_max = 64; diff --git a/core/protocol.c b/core/protocol.c index f0743c9431..e3941569eb 100644 --- a/core/protocol.c +++ b/core/protocol.c @@ -291,14 +291,14 @@ static int uwsgi_proto_check_10(struct wsgi_request *wsgi_req, char *key, char * return 0; } - if (!uwsgi_proto_key("UWSGI_FILE", 10)) { + if (uwsgi.dynamic_apps && !uwsgi_proto_key("UWSGI_FILE", 10)) { wsgi_req->file = buf; wsgi_req->file_len = len; wsgi_req->dynamic = 1; return 0; } - if (!uwsgi_proto_key("UWSGI_HOME", 10)) { + if (uwsgi.dynamic_apps && !uwsgi_proto_key("UWSGI_HOME", 10)) { wsgi_req->home = buf; wsgi_req->home_len = len; return 0; @@ -399,14 +399,14 @@ static int uwsgi_proto_check_12(struct wsgi_request *wsgi_req, char *key, char * return 0; } - if (!uwsgi_proto_key("UWSGI_SCRIPT", 12)) { + if (uwsgi.dynamic_apps && !uwsgi_proto_key("UWSGI_SCRIPT", 12)) { wsgi_req->script = buf; wsgi_req->script_len = len; wsgi_req->dynamic = 1; return 0; } - if (!uwsgi_proto_key("UWSGI_MODULE", 12)) { + if (uwsgi.dynamic_apps && !uwsgi_proto_key("UWSGI_MODULE", 12)) { wsgi_req->module = buf; wsgi_req->module_len = len; wsgi_req->dynamic = 1; @@ -471,7 +471,7 @@ static int uwsgi_proto_check_14(struct wsgi_request *wsgi_req, char *key, char * return 0; } - if (!uwsgi_proto_key("UWSGI_CALLABLE", 14)) { + if (uwsgi.dynamic_apps && !uwsgi_proto_key("UWSGI_CALLABLE", 14)) { wsgi_req->callable = buf; wsgi_req->callable_len = len; wsgi_req->dynamic = 1; diff --git a/core/uwsgi.c b/core/uwsgi.c index e2d7750a37..e9a6f09fce 100755 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -210,6 +210,7 @@ static struct uwsgi_option uwsgi_base_options[] = { {"single-interpreter", no_argument, 'i', "do not use multiple interpreters (where available)", uwsgi_opt_true, &uwsgi.single_interpreter, 0}, {"need-app", no_argument, 0, "exit if no app can be loaded", uwsgi_opt_true, &uwsgi.need_app, 0}, + {"dynamic-apps", no_argument, 0, "allows apps to be dynamically loaded via uwsgi protocol", uwsgi_opt_true, &uwsgi.dynamic_apps, 0}, {"master", no_argument, 'M', "enable master process", uwsgi_opt_true, &uwsgi.master_process, 0}, {"honour-stdin", no_argument, 0, "do not remap stdin to /dev/null", uwsgi_opt_true, &uwsgi.honour_stdin, 0}, {"emperor", required_argument, 0, "run the Emperor", uwsgi_opt_add_string_list, &uwsgi.emperor, 0}, diff --git a/uwsgi.h b/uwsgi.h index dbfb278e51..c371a04245 100755 --- a/uwsgi.h +++ b/uwsgi.h @@ -2910,6 +2910,8 @@ struct uwsgi_server { size_t argv_len; size_t environ_len; + + int dynamic_apps; }; struct uwsgi_rpc {