[Python-checkins] r59888 - python/trunk/Modules/mmapmodule.c
andrew.kuchling
python-checkins at python.org
Thu Jan 10 14:37:13 CET 2008
Author: andrew.kuchling
Date: Thu Jan 10 14:37:12 2008
New Revision: 59888
Modified:
python/trunk/Modules/mmapmodule.c
Log:
Check for fd of -1 to save fsync() and fstat() call
Modified: python/trunk/Modules/mmapmodule.c
==============================================================================
--- python/trunk/Modules/mmapmodule.c (original)
+++ python/trunk/Modules/mmapmodule.c Thu Jan 10 14:37:12 2008
@@ -1059,9 +1059,11 @@
#ifdef HAVE_FSTAT
# ifdef __VMS
/* on OpenVMS we must ensure that all bytes are written to the file */
- fsync(fd);
+ if (fd != -1) {
+ fsync(fd);
+ }
# endif
- if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
+ if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
if (map_size == 0) {
map_size = st.st_size;
} else if ((size_t)offset + (size_t)map_size > st.st_size) {
More information about the Python-checkins
mailing list