diff options
author | Neil Schemenauer <nas-github@arctrix.com> | 2017-09-05 05:13:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-05 05:13:17 (GMT) |
commit | db564238db440d4a2d8eb9d60ffb94ef291f6d30 (patch) | |
tree | b543c66c80fbab511ec65f8fba03f6cf11bb3878 /Modules | |
parent | e38d12ed34870c140016bef1e0ff10c8c3d3f213 (diff) | |
download | cpython-db564238db440d4a2d8eb9d60ffb94ef291f6d30.zip cpython-db564238db440d4a2d8eb9d60ffb94ef291f6d30.tar.gz cpython-db564238db440d4a2d8eb9d60ffb94ef291f6d30.tar.bz2 |
Revert "bpo-17852: Maintain a list of BufferedWriter objects. Flush them on exit. (#1908)" (#3337)
This reverts commit e38d12ed34870c140016bef1e0ff10c8c3d3f213.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/_iomodule.c | 2 | ||||
-rw-r--r-- | Modules/_io/_iomodule.h | 2 | ||||
-rw-r--r-- | Modules/_io/bufferedio.c | 46 |
3 files changed, 1 insertions, 49 deletions
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c index 5db44f9..f0621f4 100644 --- a/Modules/_io/_iomodule.c +++ b/Modules/_io/_iomodule.c @@ -766,8 +766,6 @@ PyInit__io(void) !(_PyIO_empty_bytes = PyBytes_FromStringAndSize(NULL, 0))) goto fail; - _Py_PyAtExit(_PyIO_atexit_flush); - state->initialized = 1; return m; diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index 1dce5da..db84037 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -183,5 +183,3 @@ extern PyObject *_PyIO_empty_str; extern PyObject *_PyIO_empty_bytes; extern PyTypeObject _PyBytesIOBuffer_Type; - -extern void _PyIO_atexit_flush(void); diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 50c87c1..189b1cd 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -196,7 +196,7 @@ bufferediobase_write(PyObject *self, PyObject *args) } -typedef struct _buffered { +typedef struct { PyObject_HEAD PyObject *raw; @@ -240,18 +240,8 @@ typedef struct _buffered { PyObject *dict; PyObject *weakreflist; - - /* a doubly-linked chained list of "buffered" objects that need to - be flushed when the process exits */ - struct _buffered *next, *prev; } buffered; -/* the actual list of buffered objects */ -static buffered buffer_list_end = { - .next = &buffer_list_end, - .prev = &buffer_list_end -}; - /* Implementation notes: @@ -397,15 +387,6 @@ _enter_buffered_busy(buffered *self) static void -remove_from_linked_list(buffered *self) -{ - self->next->prev = self->prev; - self->prev->next = self->next; - self->prev = NULL; - self->next = NULL; -} - -static void buffered_dealloc(buffered *self) { self->finalizing = 1; @@ -413,8 +394,6 @@ buffered_dealloc(buffered *self) return; _PyObject_GC_UNTRACK(self); self->ok = 0; - if (self->next != NULL) - remove_from_linked_list(self); if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)self); Py_CLEAR(self->raw); @@ -1838,33 +1817,10 @@ _io_BufferedWriter___init___impl(buffered *self, PyObject *raw, self->fast_closed_checks = (Py_TYPE(self) == &PyBufferedWriter_Type && Py_TYPE(raw) == &PyFileIO_Type); - if (self->next == NULL) { - self->prev = &buffer_list_end; - self->next = buffer_list_end.next; - buffer_list_end.next->prev = self; - buffer_list_end.next = self; - } - self->ok = 1; return 0; } -/* -* Ensure all buffered writers are flushed before proceeding with -* normal shutdown. Otherwise, if the underlying file objects get -* finalized before the buffered writer wrapping it then any buffered -* data will be lost. -*/ -void _PyIO_atexit_flush(void) -{ - while (buffer_list_end.next != &buffer_list_end) { - buffered *buf = buffer_list_end.next; - remove_from_linked_list(buf); - buffered_flush(buf, NULL); - PyErr_Clear(); - } -} - static Py_ssize_t _bufferedwriter_raw_write(buffered *self, char *start, Py_ssize_t len) { |