aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2001-11-16 10:12:59 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2001-11-16 10:12:59 +0000
commitfff56ab1242e3ad7cddf15e7e981da55d06c4da5 (patch)
treebaca68469ea73b679ac2e74aba52e7312e0ea7a8 /python
parent39f28679ed1c313bbeea85d370d95f62551bb21b (diff)
downloadlibfuse-fff56ab1242e3ad7cddf15e7e981da55d06c4da5.tar.gz
better thread management
Diffstat (limited to 'python')
-rw-r--r--python/_fusemodule.c61
1 files changed, 43 insertions, 18 deletions
diff --git a/python/_fusemodule.c b/python/_fusemodule.c
index eee4fda..2f5e79c 100644
--- a/python/_fusemodule.c
+++ b/python/_fusemodule.c
@@ -68,29 +68,58 @@ static int readlink_func(const char *path, char *link, size_t size) {
EPILOGUE
}
+static int getdir_add_entry(PyObject *w, fuse_dirh_t dh, fuse_dirfil_t df)
+{
+ PyObject *o0;
+ PyObject *o1;
+ int ret = -EINVAL;
+
+ if(!PySequence_Check(w)) {
+ printf("getdir item not sequence\n");
+ goto out;
+ }
+ if(PySequence_Length(w) != 2) {
+ printf("getdir item not len 2\n");
+ goto out;
+ }
+ o0 = PySequence_GetItem(w, 0);
+ o1 = PySequence_GetItem(w, 1);
+
+ if(!PyString_Check(o0)) {
+ printf("getdir item[0] not string\n");
+ goto out_decref;
+ }
+ if(!PyInt_Check(o1)) {
+ printf("getdir item[1] not int\n");
+ goto out_decref;
+ }
+
+ ret = df(dh, PyString_AsString(o0), PyInt_AsLong(o1));
+
+out_decref:
+ Py_DECREF(o0);
+ Py_DECREF(o1);
+
+out:
+ return ret;
+}
+
static int getdir_func(const char *path, fuse_dirh_t dh, fuse_dirfil_t df) {
PyObject *v = PyObject_CallFunction(getdir_cb, "s", path);
int i;
PROLOGUE
- if(!PySequence_Check(v)) { printf("getdir_func not sequence\n");goto OUT_DECREF; }
- for(i=0; i < PySequence_Length(v); i++) {
- PyObject *w = PySequence_GetItem(v, i);
- printf("getdir_func validate %d\n", i);
- if(!PySequence_Check(w)) { printf("getdir item not sequence\n"); goto OUT_DECREF; }
- if(PySequence_Length(w) != 2) { printf("getdir item not len 2\n"); goto OUT_DECREF; }
- if(!PyString_Check(PySequence_GetItem(w,0))){ printf("getdir item[0] not string"); goto OUT_DECREF; }
- if(!PyInt_Check(PySequence_GetItem(w, 1))) { printf("getdir item[1] not int"); goto OUT_DECREF; }
+ if(!PySequence_Check(v)) {
+ printf("getdir_func not sequence\n");
+ goto OUT_DECREF;
}
-
for(i=0; i < PySequence_Length(v); i++) {
PyObject *w = PySequence_GetItem(v, i);
- printf("getdir_func %d\n", i);
- ret = df(dh, PyString_AsString(PySequence_GetItem(w, 0)),
- PyInt_AsLong(PySequence_GetItem(w, 1)));
- if(ret) goto OUT_DECREF;
+ ret = getdir_add_entry(w, dh, df);
+ Py_DECREF(w);
+ if(ret != 0)
+ goto OUT_DECREF;
}
-
ret = 0;
EPILOGUE
@@ -191,8 +220,6 @@ int open_func(const char *path, int mode) {
static PyObject *
Fuse_main(PyObject *self, PyObject *args, PyObject *kw)
{
- PyObject *list, *item;
-
int flags=0;
struct fuse_operations op;
@@ -260,7 +287,5 @@ init_fuse(void)
d = PyModule_GetDict(m);
ErrorObject = PyErr_NewException("fuse.error", NULL, NULL);
PyDict_SetItemString(d, "error", ErrorObject);
- PyDict_SetItemString(d, "MULTITHREAD", PyInt_FromLong(FUSE_MULTITHREAD));
PyDict_SetItemString(d, "DEBUG", PyInt_FromLong(FUSE_DEBUG));
-
}