summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_disk_file.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-02-20 14:14:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-02-20 14:14:37 +0000
commit518f5d4935235da84435c69d254b826dee5186f2 (patch)
treed43f1193c288dd2f767221d9ff8e7573fc84a90c /winsup/cygwin/fhandler_disk_file.cc
parent1374b148ba05b8ff93032e3c5cfc4c9e6a85e572 (diff)
downloadcygnal-518f5d4935235da84435c69d254b826dee5186f2.tar.gz
cygnal-518f5d4935235da84435c69d254b826dee5186f2.tar.bz2
cygnal-518f5d4935235da84435c69d254b826dee5186f2.zip
* fhandler_disk_file.cc (fhandler_disk_file::opendir): Check descriptor
created by cygheap_fdnew constructor. * fhandler_virtual.cc (fhandler_virtual::opendir): Ditto. * fhandler_socket.cc (fhandler_socket::accept): Ditto and move creation of file descriptor behind blocking OS call. * net.cc (cygwin_socket): Ditto. (cygwin_rcmd): Ditto. (cygwin_rresvport): Ditto. (cygwin_rexec): Ditto. (socketpair): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc35
1 files changed, 19 insertions, 16 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index f0971e9d2..bec3c3eac 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -619,22 +619,25 @@ fhandler_disk_file::opendir (path_conv& real_name)
strcpy (dir->__d_dirname, real_name.get_win32 ());
dir->__d_dirent->d_version = __DIRENT_VERSION;
cygheap_fdnew fd;
- fd = this;
- fd->set_nohandle (true);
- dir->__d_dirent->d_fd = fd;
- dir->__d_u.__d_data.__fh = this;
- /* FindFirstFile doesn't seem to like duplicate /'s. */
- len = strlen (dir->__d_dirname);
- if (len == 0 || isdirsep (dir->__d_dirname[len - 1]))
- strcat (dir->__d_dirname, "*");
- else
- strcat (dir->__d_dirname, "\\*"); /**/
- dir->__d_cookie = __DIRENT_COOKIE;
- dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
- dir->__d_position = 0;
- dir->__d_dirhash = get_namehash ();
-
- res = dir;
+ if (fd >= 0)
+ {
+ fd = this;
+ fd->set_nohandle (true);
+ dir->__d_dirent->d_fd = fd;
+ dir->__d_u.__d_data.__fh = this;
+ /* FindFirstFile doesn't seem to like duplicate /'s. */
+ len = strlen (dir->__d_dirname);
+ if (len == 0 || isdirsep (dir->__d_dirname[len - 1]))
+ strcat (dir->__d_dirname, "*");
+ else
+ strcat (dir->__d_dirname, "\\*"); /**/
+ dir->__d_cookie = __DIRENT_COOKIE;
+ dir->__d_u.__d_data.__handle = INVALID_HANDLE_VALUE;
+ dir->__d_position = 0;
+ dir->__d_dirhash = get_namehash ();
+
+ res = dir;
+ }
}
syscall_printf ("%p = opendir (%s)", res, get_name ());