]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Cleanup the previous checkin.
authorNeal Norwitz <nnorwitz@gmail.com>
Wed, 2 Nov 2005 05:36:37 +0000 (05:36 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Wed, 2 Nov 2005 05:36:37 +0000 (05:36 +0000)
Close the fd in the close method and invalidated it.  Don't try
to close a second time when deallocating.

Modules/mmapmodule.c

index 73797cb5fe28e9b7312cba31f3bfb0c36398f7c8..51487a744647a9f0e04f23dceba9004350461482 100644 (file)
@@ -99,7 +99,8 @@ mmap_object_dealloc(mmap_object *m_obj)
 #endif /* MS_WINDOWS */
 
 #ifdef UNIX
-       close(m_obj->fd);
+       if (m_obj->fd >= 0)
+               (void) close(m_obj->fd);
        if (m_obj->data!=NULL) {
                msync(m_obj->data, m_obj->size, MS_SYNC);
                munmap(m_obj->data, m_obj->size);
@@ -137,6 +138,8 @@ mmap_close_method(mmap_object *self, PyObject *args)
 #endif /* MS_WINDOWS */
 
 #ifdef UNIX
+       (void) close(self->fd);
+       self->fd = -1;
        if (self->data != NULL) {
                munmap(self->data, self->size);
                self->data = NULL;