diff --git a/fuseparts/_fusemodule.c b/fuseparts/_fusemodule.c index 691b286..8655af5 100644 --- a/fuseparts/_fusemodule.c +++ b/fuseparts/_fusemodule.c @@ -1272,15 +1272,36 @@ poll_func(const char *path, struct fuse_file_info *fi, struct fuse_pollhandle *ph, unsigned *reventsp) { PyObject *pollhandle = Py_None; + int ret = -EINVAL; + PyObject *v; - if (ph) + PYLOCK(); + + if (ph) { pollhandle = PyCapsule_New(ph, pollhandle_name, pollhandle_destructor); + if (!pollhandle) { + PyErr_Print(); + goto OUT; + } + } #ifdef FIX_PATH_DECODING - PROLOGUE(PYO_CALLWITHFI(fi, poll_cb, O&O, &Path_AsDecodedUnicode, path, pollhandle)); + v = PYO_CALLWITHFI(fi, poll_cb, O&O, &Path_AsDecodedUnicode, path, pollhandle); #else - PROLOGUE(PYO_CALLWITHFI(fi, poll_cb, sO, path, pollhandle)); + v = PYO_CALLWITHFI(fi, poll_cb, sO, path, pollhandle); #endif + if (!v) { + PyErr_Print(); + goto OUT; + } + if (v == Py_None) { + ret = 0; + goto OUT_DECREF; + } + if (PyInt_Check(v)) { + ret = PyInt_AsLong(v); + goto OUT_DECREF; + } OUT_DECREF: Py_DECREF(v);