aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2013-01-27 10:04:16 +0200
committerEli Zaretskii2013-01-27 10:04:16 +0200
commit224f4ec1298e93e4d18bba7ea208b08c75ae3422 (patch)
tree651cf0eee0c3e66d022c1c939a5b0e9bd687ae2c /src
parentbeb6d07d1005f6dd8a17ba6f3e8406aaf47d5130 (diff)
downloademacs-224f4ec1298e93e4d18bba7ea208b08c75ae3422.tar.gz
emacs-224f4ec1298e93e4d18bba7ea208b08c75ae3422.zip
Tentative fix for bug #13546 with failure to save files on Windows.
src/w32.c (sys_open): Zero out the flags for the new file descriptor. (sys_close): Zero out the flags for the file descriptor before closing it.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/w32.c15
2 files changed, 15 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a5108f79f3d..0fd835747ce 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12013-01-27 Eli Zaretskii <eliz@gnu.org>
2
3 * w32.c (sys_open): Zero out the flags for the new file descriptor.
4 (sys_close): Zero out the flags for the file descriptor before
5 closing it. (Bug#13546)
6
12013-01-26 Eli Zaretskii <eliz@gnu.org> 72013-01-26 Eli Zaretskii <eliz@gnu.org>
2 8
3 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume) 9 * w32.c (parse_root, get_volume_info, readdir, read_unc_volume)
diff --git a/src/w32.c b/src/w32.c
index 3e300d1b9a3..802403168f0 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -3124,9 +3124,12 @@ sys_open (const char * path, int oflag, int mode)
3124 and system files. Force all file handles to be 3124 and system files. Force all file handles to be
3125 non-inheritable. */ 3125 non-inheritable. */
3126 int res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode); 3126 int res = _open (mpath, (oflag & ~_O_CREAT) | _O_NOINHERIT, mode);
3127 if (res >= 0) 3127 if (res < 0)
3128 return res; 3128 res = _open (mpath, oflag | _O_NOINHERIT, mode);
3129 return _open (mpath, oflag | _O_NOINHERIT, mode); 3129 if (res >= 0 && res < MAXDESC)
3130 fd_info[res].flags = 0;
3131
3132 return res;
3130} 3133}
3131 3134
3132int 3135int
@@ -6135,15 +6138,15 @@ sys_close (int fd)
6135 } 6138 }
6136 } 6139 }
6137 6140
6141 if (fd >= 0 && fd < MAXDESC)
6142 fd_info[fd].flags = 0;
6143
6138 /* Note that sockets do not need special treatment here (at least on 6144 /* Note that sockets do not need special treatment here (at least on
6139 NT and Windows 95 using the standard tcp/ip stacks) - it appears that 6145 NT and Windows 95 using the standard tcp/ip stacks) - it appears that
6140 closesocket is equivalent to CloseHandle, which is to be expected 6146 closesocket is equivalent to CloseHandle, which is to be expected
6141 because socket handles are fully fledged kernel handles. */ 6147 because socket handles are fully fledged kernel handles. */
6142 rc = _close (fd); 6148 rc = _close (fd);
6143 6149
6144 if (rc == 0 && fd < MAXDESC)
6145 fd_info[fd].flags = 0;
6146
6147 return rc; 6150 return rc;
6148} 6151}
6149 6152