From 6ea535a74d08b144148c0bc14c6dbfe6ab4c839e Mon Sep 17 00:00:00 2001 From: Roberto De Ioris Date: Thu, 18 Oct 2012 16:06:53 +0200 Subject: [PATCH] fixed gil usage in gevent plugin --- plugins/gevent/gevent.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/gevent/gevent.c b/plugins/gevent/gevent.c index a5595f87..b7b7e287 100644 --- a/plugins/gevent/gevent.c +++ b/plugins/gevent/gevent.c @@ -316,6 +316,13 @@ PyMethodDef uwsgi_gevent_my_signal_def[] = { {"uwsgi_gevent_my_signal", py_uwsgi PyMethodDef uwsgi_gevent_signal_handler_def[] = { {"uwsgi_gevent_signal_handler", py_uwsgi_gevent_signal_handler, METH_VARARGS, ""} }; PyMethodDef uwsgi_gevent_unix_signal_handler_def[] = { {"uwsgi_gevent_unix_signal_handler", py_uwsgi_gevent_graceful, METH_VARARGS, ""} }; +void gil_gevent_get() { + pthread_setspecific(up.upt_gil_key, (void *) PyGILState_Ensure()); +} + +void gil_gevent_release() { + PyGILState_Release((PyGILState_STATE) pthread_getspecific(up.upt_gil_key)); +} void gevent_loop() { @@ -326,6 +333,9 @@ void gevent_loop() { // get the GIL UWSGI_GET_GIL + up.gil_get = gil_gevent_get; + up.gil_release = gil_gevent_release; + struct uwsgi_socket *uwsgi_sock = uwsgi.sockets; if (uwsgi.async < 2) {