1. nasuni
  2. Untitled project
  3. fsnix

Commits

John Mulligan  committed 87e7f6c

fslib: make fdlistdir/fditerdir dup the fd it is given

This is a minor backwards incompatible change. Use of the previous
version of the API had demonstrated that the previous approach was
error prone because any time you wanted to do something practical
with the dir fd you'd have to remember to dup it. There could have
also been potential issues with race conditions in multithreaded
code.

  • Participants
  • Parent commits 748162f
  • Branches default

Comments (0)

Files changed (1)

File fsnix/fslib.c

View file
     reslist = PyList_New(0);
     if (reslist == NULL) return NULL;
 
-    dirh = fdopendir(dirfd);
+    dirh = fdopendir(dup(dirfd));
     if (dirh == NULL) {
         Py_XDECREF(reslist);
         PyErr_SetFromErrno(PyExc_OSError);
     }
 
     Py_BEGIN_ALLOW_THREADS
-    temp = fdopendir(dirfd);
+    temp = fdopendir(dup(dirfd));
     Py_END_ALLOW_THREADS
     if (temp == NULL) {
         PyErr_SetFromErrno(PyExc_OSError);