From 304f847dc62fb5bb5a735d7806cdfe103e6d2a2f Mon Sep 17 00:00:00 2001 From: Unbit Date: Tue, 10 Dec 2013 09:06:27 +0100 Subject: [PATCH] added sharedarea_update api --- core/sharedarea.c | 7 +++++++ plugins/python/uwsgi_pymodule.c | 16 ++++++++++++++++ uwsgi.h | 1 + 3 files changed, 24 insertions(+) diff --git a/core/sharedarea.c b/core/sharedarea.c index dcb91d2e..cba0d6f6 100644 --- a/core/sharedarea.c +++ b/core/sharedarea.c @@ -26,6 +26,13 @@ struct uwsgi_sharedarea *uwsgi_sharedarea_get_by_id(int id, uint64_t pos) { return sa; } +int uwsgi_sharedarea_update(int id) { + struct uwsgi_sharedarea *sa = uwsgi_sharedarea_get_by_id(id, 0); + if (!sa) return -1; + sa->updates++; + return 0; +} + int uwsgi_sharedarea_rlock(int id) { struct uwsgi_sharedarea *sa = uwsgi_sharedarea_get_by_id(id, 0); if (!sa) return -1; diff --git a/plugins/python/uwsgi_pymodule.c b/plugins/python/uwsgi_pymodule.c index c87a1c15..f07941b3 100644 --- a/plugins/python/uwsgi_pymodule.c +++ b/plugins/python/uwsgi_pymodule.c @@ -1512,6 +1512,22 @@ PyObject *py_uwsgi_sharedarea_write(PyObject * self, PyObject * args) { return Py_None; } +PyObject *py_uwsgi_sharedarea_update(PyObject * self, PyObject * args) { + int id; + + if (!PyArg_ParseTuple(args, "i:sharedarea_update", &id)) { + return NULL; + } + + if (uwsgi_sharedarea_update(id)) { + return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_update()"); + } + + Py_INCREF(Py_None); + return Py_None; + +} + PyObject *py_uwsgi_sharedarea_rlock(PyObject * self, PyObject * args) { int id; diff --git a/uwsgi.h b/uwsgi.h index bffc6152..00ff2a4b 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -4605,6 +4605,7 @@ int uwsgi_sharedarea_wait(int, int, int); int uwsgi_sharedarea_unlock(int); int uwsgi_sharedarea_rlock(int); int uwsgi_sharedarea_wlock(int); +int uwsgi_sharedarea_update(int); struct uwsgi_sharedarea *uwsgi_sharedarea_get_by_id(int, uint64_t); int uwsgi_websocket_send_from_sharedarea(struct wsgi_request *, int, uint64_t, uint64_t);