From 518f5d4935235da84435c69d254b826dee5186f2 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 20 Feb 2003 14:14:37 +0000 Subject: * 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. --- winsup/cygwin/fhandler_disk_file.cc | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'winsup/cygwin/fhandler_disk_file.cc') 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 ()); -- cgit v1.2.3