diff --git a/contrib/pypy/uwsgi_pypy_greenlets.py b/contrib/pypy/uwsgi_pypy_greenlets.py index f915caf2..7843f177 100644 --- a/contrib/pypy/uwsgi_pypy_greenlets.py +++ b/contrib/pypy/uwsgi_pypy_greenlets.py @@ -54,7 +54,7 @@ def uwsgi_pypy_greenlet_switch(wsgi_req): # update current running greenlet lib.uwsgi.wsgi_req = wsgi_req -if lib.uwsgi.async <= 1: +if lib.uwsgi.async < 1: raise Exception("pypy greenlets require async mode !!!") lib.uwsgi.schedule_to_main = uwsgi_pypy_greenlet_switch lib.uwsgi.schedule_to_req = uwsgi_pypy_greenlet_schedule diff --git a/core/async.c b/core/async.c index dc87ae22..b4d342c6 100644 --- a/core/async.c +++ b/core/async.c @@ -165,7 +165,7 @@ static void async_expire_timeouts(uint64_t now) { int async_add_fd_read(struct wsgi_request *wsgi_req, int fd, int timeout) { - if (uwsgi.async < 2 || !uwsgi.async_waiting_fd_table){ + if (uwsgi.async < 1 || !uwsgi.async_waiting_fd_table){ uwsgi_log_verbose("ASYNC call without async mode !!!\n"); return -1; } @@ -257,7 +257,7 @@ static int async_wait_fd_read2(int fd0, int fd1, int timeout, int *fd) { void async_add_timeout(struct wsgi_request *wsgi_req, int timeout) { - if (uwsgi.async < 2 || !uwsgi.rb_async_timeouts) { + if (uwsgi.async < 1 || !uwsgi.rb_async_timeouts) { uwsgi_log_verbose("ASYNC call without async mode !!!\n"); return; } @@ -272,7 +272,7 @@ void async_add_timeout(struct wsgi_request *wsgi_req, int timeout) { int async_add_fd_write(struct wsgi_request *wsgi_req, int fd, int timeout) { - if (uwsgi.async < 2 || !uwsgi.async_waiting_fd_table) { + if (uwsgi.async < 1 || !uwsgi.async_waiting_fd_table) { uwsgi_log_verbose("ASYNC call without async mode !!!\n"); return -1; } @@ -406,7 +406,7 @@ static int uwsgi_async_wait_milliseconds_hook(int timeout) { void async_loop() { - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { uwsgi_log("the async loop engine requires async mode (--async )\n"); exit(1); } diff --git a/core/init.c b/core/init.c index 09421bca..940e78d7 100644 --- a/core/init.c +++ b/core/init.c @@ -106,7 +106,7 @@ void uwsgi_init_default() { uwsgi.forkbomb_delay = 2; - uwsgi.async = 1; + uwsgi.async = 0; uwsgi.listen_queue = 100; uwsgi.cheaper_overload = 3; @@ -419,7 +419,7 @@ pid_t uwsgi_daemonize2() { // fix/check related options void sanitize_args() { - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { uwsgi.cores = uwsgi.async; } diff --git a/core/uwsgi.c b/core/uwsgi.c index ae9d2f83..1a9abb88 100644 --- a/core/uwsgi.c +++ b/core/uwsgi.c @@ -1228,7 +1228,7 @@ void gracefully_kill(int signum) { } // still not found a way to gracefully reload in async mode - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { exit(UWSGI_RELOAD_CODE); } @@ -2669,7 +2669,7 @@ int uwsgi_start(void *v_argv) { } } - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { if ((unsigned long) uwsgi.max_fd < (unsigned long) uwsgi.async) { uwsgi_log_initial("- your current max open files limit is %lu, this is lower than requested async cores !!! -\n", (unsigned long) uwsgi.max_fd); uwsgi.rl.rlim_cur = uwsgi.async; @@ -2977,7 +2977,7 @@ unsafe: uwsgi_log("*** Operational MODE: threaded ***\n"); } } - else if (uwsgi.async > 1) { + else if (uwsgi.async > 0) { if (uwsgi.numproc > 1) { uwsgi_log("*** Operational MODE: preforking+async ***\n"); } @@ -3345,7 +3345,7 @@ void uwsgi_worker_run() { // some apps could be mounted only on specific workers uwsgi_init_worker_mount_apps(); - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { // a stack of unused cores uwsgi.async_queue_unused = uwsgi_malloc(sizeof(struct wsgi_request *) * uwsgi.async); @@ -3485,7 +3485,7 @@ void uwsgi_ignition() { uwsgi_log("your loop engine died. R.I.P.\n"); } else { - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { simple_loop(); } else { diff --git a/plugins/asyncio/asyncio.c b/plugins/asyncio/asyncio.c index a5252307..6a6aab1e 100644 --- a/plugins/asyncio/asyncio.c +++ b/plugins/asyncio/asyncio.c @@ -314,7 +314,7 @@ static void asyncio_loop() { uwsgi.schedule_fix = uwsgi_asyncio_schedule_fix; - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { uwsgi_log("the asyncio loop engine requires async mode (--async )\n"); exit(1); } diff --git a/plugins/cgi/cgi_plugin.c b/plugins/cgi/cgi_plugin.c index 2dcaa90e..d343d59f 100644 --- a/plugins/cgi/cgi_plugin.c +++ b/plugins/cgi/cgi_plugin.c @@ -731,7 +731,7 @@ clear2: // now wait for process exit/death // in async mode we need a trick... - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { pid_t diedpid = waitpid(cgi_pid, &waitpid_status, WNOHANG); if (diedpid < 0) { uwsgi_error("waitpid()"); diff --git a/plugins/coroae/coroae.c b/plugins/coroae/coroae.c index 2113a743..837f0543 100644 --- a/plugins/coroae/coroae.c +++ b/plugins/coroae/coroae.c @@ -356,7 +356,7 @@ static void coroae_wait_condvar(SV *cv) { static void coroae_loop() { - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { if (uwsgi.mywid == 1) { uwsgi_log("the Coro::AnyEvent loop engine requires async mode (--async )\n"); } diff --git a/plugins/fiber/fiber.c b/plugins/fiber/fiber.c index ca9191eb..30603ae0 100644 --- a/plugins/fiber/fiber.c +++ b/plugins/fiber/fiber.c @@ -83,7 +83,7 @@ static int fiber_init() { static void fiber_init_apps(void) { if (!ufiber.enabled) return; - if (uwsgi.async <= 1) { + if (uwsgi.async < 1) { uwsgi_log("the fiber loop engine requires async mode\n"); exit(1); } diff --git a/plugins/gevent/gevent.c b/plugins/gevent/gevent.c index 099bfc91..e8cd3875 100644 --- a/plugins/gevent/gevent.c +++ b/plugins/gevent/gevent.c @@ -368,7 +368,7 @@ static void gevent_loop() { struct uwsgi_socket *uwsgi_sock = uwsgi.sockets; - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { uwsgi_log("the gevent loop engine requires async mode (--async )\n"); exit(1); } diff --git a/plugins/glusterfs/glusterfs.c b/plugins/glusterfs/glusterfs.c index 92616b6c..33f0ddfc 100644 --- a/plugins/glusterfs/glusterfs.c +++ b/plugins/glusterfs/glusterfs.c @@ -270,7 +270,7 @@ static int uwsgi_glusterfs_request(struct wsgi_request *wsgi_req) { // skip body on HEAD if (uwsgi_strncmp(wsgi_req->method, wsgi_req->method_len, "HEAD", 4)) { size_t remains = st.st_size; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { if (uwsgi_glusterfs_read_async(wsgi_req, fd, remains)) goto end; } else { diff --git a/plugins/greenlet/greenlet.c b/plugins/greenlet/greenlet.c index f494a3b5..7c69fa8e 100644 --- a/plugins/greenlet/greenlet.c +++ b/plugins/greenlet/greenlet.c @@ -116,7 +116,7 @@ static void greenlet_init_apps(void) { if (!ugl.enabled) return; - if (uwsgi.async <= 1) { + if (uwsgi.async < 1) { uwsgi_log("the greenlet suspend engine requires async mode\n"); exit(1); } diff --git a/plugins/lua/lua_plugin.c b/plugins/lua/lua_plugin.c index fe810457..0bd96a7e 100644 --- a/plugins/lua/lua_plugin.c +++ b/plugins/lua/lua_plugin.c @@ -843,7 +843,7 @@ static int uwsgi_lua_request(struct wsgi_request *wsgi_req) { } lua_pop(L, 1); lua_pushvalue(L, -1); - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { return UWSGI_AGAIN; } } diff --git a/plugins/psgi/psgi_plugin.c b/plugins/psgi/psgi_plugin.c index a7c46026..4fb6de91 100644 --- a/plugins/psgi/psgi_plugin.c +++ b/plugins/psgi/psgi_plugin.c @@ -405,7 +405,7 @@ SV *build_psgi_env(struct wsgi_request *wsgi_req) { if (!hv_store(env, "psgi.run_once", 13, newSViv(0), 0)) goto clear; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { if (!hv_store(env, "psgi.nonblocking", 16, newSViv(1), 0)) goto clear; } else { @@ -631,7 +631,7 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) { } while (psgi_response(wsgi_req, wsgi_req->async_result) != UWSGI_OK) { - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { FREETMPS; LEAVE; return UWSGI_AGAIN; @@ -861,7 +861,7 @@ static void uwsgi_perl_atexit() { return; // managing atexit in async mode is a real pain...skip it for now - if (uwsgi.async > 1) + if (uwsgi.async > 0) return; realstuff: diff --git a/plugins/psgi/psgi_response.c b/plugins/psgi/psgi_response.c index e20cfc4d..b5c5614f 100644 --- a/plugins/psgi/psgi_response.c +++ b/plugins/psgi/psgi_response.c @@ -148,7 +148,7 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) { chitem = SvPV( chunk, hlen); if (hlen <= 0) { SvREFCNT_dec(chunk); - if (uwsgi.async > 1 && wsgi_req->async_force_again) { + if (uwsgi.async > 0 && wsgi_req->async_force_again) { wsgi_req->async_placeholder = (SV *) *hitem; return UWSGI_AGAIN; } @@ -161,7 +161,7 @@ int psgi_response(struct wsgi_request *wsgi_req, AV *response) { break; } SvREFCNT_dec(chunk); - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { wsgi_req->async_placeholder = (SV *) *hitem; wsgi_req->async_force_again = 1; return UWSGI_AGAIN; diff --git a/plugins/pypy/pypy_setup.py b/plugins/pypy/pypy_setup.py index 769c2386..67533ddc 100644 --- a/plugins/pypy/pypy_setup.py +++ b/plugins/pypy/pypy_setup.py @@ -980,7 +980,7 @@ def uwsgi_pypy_continulet_switch(wsgi_req): lib.uwsgi.wsgi_req = wsgi_req def uwsgi_pypy_setup_continulets(): - if lib.uwsgi.async <= 1: + if lib.uwsgi.async < 1: raise Exception("pypy continulets require async mode !!!") lib.uwsgi.schedule_to_main = uwsgi_pypy_continulet_switch lib.uwsgi.schedule_to_req = uwsgi_pypy_continulet_schedule diff --git a/plugins/python/pump_subhandler.c b/plugins/python/pump_subhandler.c index 0e4f026f..42a84aef 100644 --- a/plugins/python/pump_subhandler.c +++ b/plugins/python/pump_subhandler.c @@ -255,7 +255,7 @@ int uwsgi_response_subhandler_pump(struct wsgi_request *wsgi_req) { goto clear; } - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { return UWSGI_AGAIN; } diff --git a/plugins/python/python_plugin.c b/plugins/python/python_plugin.c index 9ab4c671..37f625af 100644 --- a/plugins/python/python_plugin.c +++ b/plugins/python/python_plugin.c @@ -361,7 +361,7 @@ void uwsgi_python_atexit() { return; // managing atexit in async mode is a real pain...skip it for now - if (uwsgi.async > 1) + if (uwsgi.async > 0) return; realstuff: @@ -1126,7 +1126,7 @@ void uwsgi_python_init_apps() { } // prepare for stack suspend/resume - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { up.current_recursion_depth = uwsgi_malloc(sizeof(int)*uwsgi.async); up.current_frame = uwsgi_malloc(sizeof(struct _frame)*uwsgi.async); } diff --git a/plugins/python/pyutils.c b/plugins/python/pyutils.c index f4b1ef3d..400c9f49 100644 --- a/plugins/python/pyutils.c +++ b/plugins/python/pyutils.c @@ -289,7 +289,7 @@ int uwsgi_python_call(struct wsgi_request *wsgi_req, PyObject *callable, PyObjec if (wsgi_req->async_result) { while ( manage_python_response(wsgi_req) != UWSGI_OK) { - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { return UWSGI_AGAIN; } } diff --git a/plugins/python/raw.c b/plugins/python/raw.c index c577bf1a..47f66d20 100644 --- a/plugins/python/raw.c +++ b/plugins/python/raw.c @@ -71,7 +71,7 @@ int uwsgi_request_python_raw(struct wsgi_request *wsgi_req) { int ret = manage_raw_response(wsgi_req); if (ret == UWSGI_AGAIN) { wsgi_req->async_force_again = 1; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { UWSGI_RELEASE_GIL return UWSGI_AGAIN; } continue; diff --git a/plugins/python/web3_subhandler.c b/plugins/python/web3_subhandler.c index 231a538d..48fe1623 100644 --- a/plugins/python/web3_subhandler.c +++ b/plugins/python/web3_subhandler.c @@ -164,7 +164,7 @@ int uwsgi_response_subhandler_web3(struct wsgi_request *wsgi_req) { if (!wsgi_req->async_placeholder) { goto clear; } - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { return UWSGI_AGAIN; } } diff --git a/plugins/python/wsgi_handlers.c b/plugins/python/wsgi_handlers.c index 6cc091b3..94a398a1 100644 --- a/plugins/python/wsgi_handlers.c +++ b/plugins/python/wsgi_handlers.c @@ -405,7 +405,7 @@ int uwsgi_request_wsgi(struct wsgi_request *wsgi_req) { while (wi->response_subhandler(wsgi_req) != UWSGI_OK) { - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { UWSGI_RELEASE_GIL wsgi_req->async_force_again = 1; return UWSGI_AGAIN; diff --git a/plugins/python/wsgi_subhandler.c b/plugins/python/wsgi_subhandler.c index 7eb57b08..3112ddb9 100644 --- a/plugins/python/wsgi_subhandler.c +++ b/plugins/python/wsgi_subhandler.c @@ -170,7 +170,7 @@ void *uwsgi_request_subhandler_wsgi(struct wsgi_request *wsgi_req, struct uwsgi_ PyDict_SetItemString(wsgi_req->async_environ, "wsgi.file_wrapper", wi->sendfile); - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { PyDict_SetItemString(wsgi_req->async_environ, "x-wsgiorg.fdevent.readable", wi->eventfd_read); PyDict_SetItemString(wsgi_req->async_environ, "x-wsgiorg.fdevent.writable", wi->eventfd_write); PyDict_SetItemString(wsgi_req->async_environ, "x-wsgiorg.fdevent.timeout", Py_None); @@ -269,7 +269,7 @@ int uwsgi_response_subhandler_wsgi(struct wsgi_request *wsgi_req) { if (!wsgi_req->async_placeholder) { goto exception; } - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { return UWSGI_AGAIN; } } diff --git a/plugins/rados/rados.c b/plugins/rados/rados.c index a12a15b8..86448bd5 100644 --- a/plugins/rados/rados.c +++ b/plugins/rados/rados.c @@ -90,7 +90,7 @@ static void uwsgi_rados_read_async_cb(rados_completion_t comp, void *data) { } static int uwsgi_rados_delete(struct wsgi_request *wsgi_req, rados_ioctx_t ctx, char *key, int timeout) { - if (uwsgi.async <= 1) { + if (uwsgi.async < 1) { return rados_remove(ctx, key); } struct uwsgi_rados_io *urio = &urados.urio[wsgi_req->async_id]; @@ -147,7 +147,7 @@ static int uwsgi_rados_put(struct wsgi_request *wsgi_req, rados_ioctx_t ctx, cha ssize_t body_len = 0; char *body = uwsgi_request_body_read(wsgi_req, UMIN(remains, 32768) , &body_len); if (!body || body == uwsgi.empty) goto error; - if (uwsgi.async <= 1) { + if (uwsgi.async < 1) { if (rados_write(ctx, key, body, body_len, off) < 0) { return -1; } @@ -368,7 +368,7 @@ static void uwsgi_rados_propfind(struct wsgi_request *wsgi_req, rados_ioctx_t ct while(rados_objects_list_next(ctx_list, (const char **)&entry, NULL) == 0) { uint64_t stat_size = 0; time_t stat_mtime = 0; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { if (uwsgi_rados_async_stat(urio, ctx, entry, &stat_size, &stat_mtime, timeout) < 0) goto end; } else { @@ -513,7 +513,7 @@ static void uwsgi_rados_setup() { } // now initialize a pthread_mutex for each async core - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { int i; urados.urio = uwsgi_calloc(sizeof(struct uwsgi_rados_io) * uwsgi.async); for(i=0;iasync_id]; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { // no need to lock here (the rid protect us) if (pipe(urio->fds)) { uwsgi_error("uwsgi_rados_read_async()/pipe()"); @@ -664,7 +664,7 @@ static int uwsgi_rados_request(struct wsgi_request *wsgi_req) { goto end; } - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { ret = uwsgi_rados_async_stat(urio, ctx, filename, &stat_size, &stat_mtime, timeout); } else { @@ -738,7 +738,7 @@ static int uwsgi_rados_request(struct wsgi_request *wsgi_req) { // skip body on HEAD if (uwsgi_strncmp(wsgi_req->method, wsgi_req->method_len, "HEAD", 4)) { size_t remains = stat_size; - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { if (uwsgi_rados_read_async(wsgi_req, ctx, filename, remains, timeout)) goto end; } else { @@ -747,7 +747,7 @@ static int uwsgi_rados_request(struct wsgi_request *wsgi_req) { } end: - if (uwsgi.async > 1) { + if (uwsgi.async > 0) { close(urio->fds[0]); close(urio->fds[1]); } diff --git a/plugins/stackless/stackless.c b/plugins/stackless/stackless.c index 94cfd673..0516c9f0 100644 --- a/plugins/stackless/stackless.c +++ b/plugins/stackless/stackless.c @@ -84,7 +84,7 @@ static void stackless_init_apps(void) { if (!usl.enabled) return; - if (uwsgi.async <= 1) { + if (uwsgi.async < 1) { uwsgi_log("the stackless suspend engine requires async mode\n"); exit(1); } diff --git a/plugins/tornado/tornado.c b/plugins/tornado/tornado.c index 9030506b..d7335104 100644 --- a/plugins/tornado/tornado.c +++ b/plugins/tornado/tornado.c @@ -342,7 +342,7 @@ static void tornado_loop() { uwsgi.schedule_fix = uwsgi_tornado_schedule_fix; - if (uwsgi.async < 2) { + if (uwsgi.async < 1) { uwsgi_log("the tornado loop engine requires async mode (--async )\n"); exit(1); }