Message110669
Hmm, correct me if following understanding is wrong somewhere...
1. File.close() is actually file_close(), and is calling close_the_file().
2. Returns immediately because local_fp == f->f_fp is already NULL.
The return value is None.
3. sts is non-NULL, so PyMem_Free(f->f_setbuf) happens.
4. There is no system call for FILE object, so thread won't wait for close(2) completion.
Maybe can we fix this issue by the patch like this? I moved PyMem_Free
into close_the_file(), and called it only when close operation
succeeded.
Index: Objects/fileobject.c
===================================================================
--- Objects/fileobject.c (revision 82910)
+++ Objects/fileobject.c (working copy)
@@ -371,9 +371,14 @@
Py_END_ALLOW_THREADS
if (sts == EOF)
return PyErr_SetFromErrno(PyExc_IOError);
- if (sts != 0)
+ if (sts != 0) {
+ PyMem_Free(f->f_setbuf);
+ f->f_setbuf = NULL;
return PyInt_FromLong((long)sts);
+ }
}
+ PyMem_Free(f->f_setbuf);
+ f->f_setbuf = NULL;
}
Py_RETURN_NONE;
}
@@ -567,12 +572,7 @@
static PyObject *
file_close(PyFileObject *f)
{
- PyObject *sts = close_the_file(f);
- if (sts) {
- PyMem_Free(f->f_setbuf);
- f->f_setbuf = NULL;
- }
- return sts;
+ return close_the_file(f);
} |
|
Date |
User |
Action |
Args |
2010-07-18 17:35:39 | ocean-city | set | recipients:
+ ocean-city, pitrou |
2010-07-18 17:35:39 | ocean-city | set | messageid: <1279474539.68.0.852084808182.issue9295@psf.upfronthosting.co.za> |
2010-07-18 17:35:38 | ocean-city | link | issue9295 messages |
2010-07-18 17:35:38 | ocean-city | create | |
|