summaryrefslogtreecommitdiff
path: root/Include/fileobject.h
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-04-06 23:11:17 +0000
committerGregory P. Smith <greg@mad-scientist.com>2008-04-06 23:11:17 +0000
commitaa63d0d4af3db832b390ac74517af5eb799540e5 (patch)
tree86818f84f404fef73ee3f56eb0945334b4d52cb8 /Include/fileobject.h
parentee76777846124bb5b7e08feb488d5bab949c76a5 (diff)
downloadcpython-git-aa63d0d4af3db832b390ac74517af5eb799540e5.tar.gz
Make file objects as thread safe as the underlying libc FILE* implementation.
close() will now raise an IOError if any operations on the file object are currently in progress in other threads. Most code was written by Antoine Pitrou (pitrou). Additional testing, documentation and test suite cleanup done by me (gregory.p.smith). Fixes issue 815646 and 595601 (as well as many other bugs and references to this problem dating back to the dawn of Python).
Diffstat (limited to 'Include/fileobject.h')
-rw-r--r--Include/fileobject.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Include/fileobject.h b/Include/fileobject.h
index 75b0f038ec..56fae81fe4 100644
--- a/Include/fileobject.h
+++ b/Include/fileobject.h
@@ -25,6 +25,8 @@ typedef struct {
int f_skipnextlf; /* Skip next \n */
PyObject *f_encoding;
PyObject *weakreflist; /* List of weak references */
+ int unlocked_count; /* Num. currently running sections of code
+ using f_fp with the GIL released. */
} PyFileObject;
PyAPI_DATA(PyTypeObject) PyFile_Type;
@@ -38,6 +40,8 @@ PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *);
PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *,
int (*)(FILE *));
PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *);
+PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *);
+PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *);
PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *);
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);