refactored sharedarea read

This commit is contained in:
Unbit
2013-11-30 18:30:52 +00:00
parent 92b6c62cac
commit b934ac9588
6 changed files with 23 additions and 9 deletions
+5 -2
View File
@@ -1600,14 +1600,17 @@ PyObject *py_uwsgi_sharedarea_read(PyObject * self, PyObject * args) {
#endif
UWSGI_RELEASE_GIL
int r = uwsgi_sharedarea_read(id, pos, storage, len);
int64_t rlen = uwsgi_sharedarea_read(id, pos, storage, len);
UWSGI_GET_GIL
if (r) {
if (rlen < 0) {
Py_DECREF(ret);
return PyErr_Format(PyExc_ValueError, "error calling uwsgi_sharedarea_read()");
}
// HACK: we are safe as rlen can only be lower or equal to len
Py_SIZE(ret) = rlen;
return ret;
}
+6
View File
@@ -30,6 +30,12 @@
#define PYTHREE
#endif
#if (PY_VERSION_HEX < 0x02060000)
#ifndef Py_SIZE
#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size)
#endif
#endif
#define UWSGI_GET_GIL up.gil_get();
#define UWSGI_RELEASE_GIL up.gil_release();