Skip to content

Commit 5e54c0c

Browse files
authored
Merge pull request #83 from brgl/fix-poll-func
pull PyCapsule_New() into the PYLOCK() section in poll_func()
2 parents b330bcc + 26ee2c9 commit 5e54c0c

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

fuseparts/_fusemodule.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,15 +1272,36 @@ poll_func(const char *path, struct fuse_file_info *fi,
12721272
struct fuse_pollhandle *ph, unsigned *reventsp)
12731273
{
12741274
PyObject *pollhandle = Py_None;
1275+
int ret = -EINVAL;
1276+
PyObject *v;
12751277

1276-
if (ph)
1278+
PYLOCK();
1279+
1280+
if (ph) {
12771281
pollhandle = PyCapsule_New(ph, pollhandle_name, pollhandle_destructor);
1282+
if (!pollhandle) {
1283+
PyErr_Print();
1284+
goto OUT;
1285+
}
1286+
}
12781287

12791288
#ifdef FIX_PATH_DECODING
1280-
PROLOGUE(PYO_CALLWITHFI(fi, poll_cb, O&O, &Path_AsDecodedUnicode, path, pollhandle));
1289+
v = PYO_CALLWITHFI(fi, poll_cb, O&O, &Path_AsDecodedUnicode, path, pollhandle);
12811290
#else
1282-
PROLOGUE(PYO_CALLWITHFI(fi, poll_cb, sO, path, pollhandle));
1291+
v = PYO_CALLWITHFI(fi, poll_cb, sO, path, pollhandle);
12831292
#endif
1293+
if (!v) {
1294+
PyErr_Print();
1295+
goto OUT;
1296+
}
1297+
if (v == Py_None) {
1298+
ret = 0;
1299+
goto OUT_DECREF;
1300+
}
1301+
if (PyInt_Check(v)) {
1302+
ret = PyInt_AsLong(v);
1303+
goto OUT_DECREF;
1304+
}
12841305

12851306
OUT_DECREF:
12861307
Py_DECREF(v);

0 commit comments

Comments
 (0)