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_virtual.cc | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'winsup/cygwin/fhandler_virtual.cc') diff --git a/winsup/cygwin/fhandler_virtual.cc b/winsup/cygwin/fhandler_virtual.cc index 4316efa69..f8f3519a8 100644 --- a/winsup/cygwin/fhandler_virtual.cc +++ b/winsup/cygwin/fhandler_virtual.cc @@ -74,16 +74,19 @@ fhandler_virtual::opendir (path_conv& pc) strcpy (dir->__d_dirname, get_name ()); 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; - 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; + 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