diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-10-30 09:44:47 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-10-30 09:44:47 +0000 |
commit | 751bbaf96ae7ee249d7f5cb243b1239779ca0530 (patch) | |
tree | a7c6fbb535a816767ae9a7231458d3688bea8b17 /winsup/cygwin/fhandler_windows.cc | |
parent | 0160e166ee3c6a87c9e95c2d75ee2d2a0c4c2a29 (diff) | |
download | cygnal-751bbaf96ae7ee249d7f5cb243b1239779ca0530.tar.gz cygnal-751bbaf96ae7ee249d7f5cb243b1239779ca0530.tar.bz2 cygnal-751bbaf96ae7ee249d7f5cb243b1239779ca0530.zip |
* devices.in (dev_cygdrive_storage): Map to \Device\Null.
(dev_storage): Map /dev and /dev/windows to \Device\Null.
* devices.cc: Regenerate.
* dir.cc (opendir): Create unique id. Explain why.
* fhandler.h (fhandler_dev::get_dev): Implement inline.
(fhandler_cygdrive::close): Drop declaration.
(fhandler_cygdrive::get_dev): Implement inline.
(fhandler_windows::get_hwnd): Ditto.
(fhandler_windows::set_close_on_exec): Drop declaration.
(fhandler_windows::fixup_after_fork): Ditto.
* fhandler_dev.cc (fhandler_dev::open): Call fhandler_disk_file::open
without O_CREAT flag. Explain why. Create \Device\Null handle if
/dev/ doesn't actually exist.
(fhandler_dev::close): Drop nohandle case.
(fhandler_dev::fstatvfs): Drop nohandle check. Test for fs_got_fs
instead. Set ST_RDONLY fs flag for simulated /dev.
(fhandler_dev::opendir): If /dev doesn't exist, call open() to create
fake \Device\Null handle. Don't set nohandle. Set dir_exists
correctly.
(fhandler_dev::rewinddir): Call fhandler_disk_file::rewinddir only if
/dev is a real directory.
* fhandler_disk_file.cc (fhandler_disk_file::opendir): If called for
the cygdrive dir, call open() to create fake \Device\Null handle.
Only attach __DIR_mounts buffer to dir if not called for cygdrive dir.
Don't set nohandle.
(fhandler_cygdrive::open): Create \Device\Null handle.
(fhandler_cygdrive::close): Remove.
(fhandler_cygdrive::fstatvfs): Set ST_RDONLY fs flag.
* fhandler_windows.cc (fhandler_windows::open): Create \Device\Null
handle.
(fhandler_windows::read): Don't add io_handle to WFMO handle array.
Change subsequent test for return value accordingly. Fix test for
"message arrived".
(fhandler_windows::set_close_on_exec): Remove.
(fhandler_windows::fixup_after_fork): Remove.
* path.h (path_conv::set_path): Make sure wide_path is NULL when
setting a new path.
* select.cc (peek_windows): Use correct hWnd value, not io_handle.
(fhandler_windows::select_read): Don't use io_handle as wait object.
(fhandler_windows::select_write): Ditto.
(fhandler_windows::select_except): Ditto.
Diffstat (limited to 'winsup/cygwin/fhandler_windows.cc')
-rw-r--r-- | winsup/cygwin/fhandler_windows.cc | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc index 12ab5265b..34388f76f 100644 --- a/winsup/cygwin/fhandler_windows.cc +++ b/winsup/cygwin/fhandler_windows.cc @@ -1,7 +1,7 @@ /* fhandler_windows.cc: code to access windows message queues. - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2011, 2012 - Red Hat, Inc. + Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, 2011, 2012, + 2013 Red Hat, Inc. Written by Sergey S. Okhapkin (sos@prospect.com.ru). Feedback and testing by Andy Piper (andyp@parallax.co.uk). @@ -54,12 +54,9 @@ fhandler_windows::fhandler_windows () } int -fhandler_windows::open (int flags, mode_t) +fhandler_windows::open (int flags, mode_t mode) { - set_flags ((flags & ~O_TEXT) | O_BINARY); - close_on_exec (true); - set_open_status (); - return 1; + return fhandler_base::open ((flags & ~O_TEXT) | O_BINARY, mode); } ssize_t __stdcall @@ -96,10 +93,10 @@ fhandler_windows::read (void *buf, size_t& len) return; } - HANDLE w4[3] = { get_handle (), }; - set_signal_arrived here (w4[1]); - DWORD cnt = 2; - if ((w4[cnt] = pthread::get_cancel_event ()) != NULL) + HANDLE w4[2]; + set_signal_arrived here (w4[0]); + DWORD cnt = 1; + if ((w4[1] = pthread::get_cancel_event ()) != NULL) ++cnt; for (;;) { @@ -109,6 +106,19 @@ fhandler_windows::read (void *buf, size_t& len) MWMO_INPUTAVAILABLE)) { case WAIT_OBJECT_0: + if (_my_tls.call_signal_handler ()) + continue; + len = (size_t) -1; + set_errno (EINTR); + break; + case WAIT_OBJECT_0 + 1: + if (cnt > 1) /* WAIT_OBJECT_0 + 1 is the cancel event object. */ + { + pthread::static_cancel_self (); + break; + } + /*FALLTHRU*/ + case WAIT_OBJECT_0 + 2: if (!PeekMessageW (ptr, hWnd_, 0, 0, PM_REMOVE)) { len = (size_t) -1; @@ -119,15 +129,6 @@ fhandler_windows::read (void *buf, size_t& len) else len = sizeof (MSG); break; - case WAIT_OBJECT_0 + 1: - if (_my_tls.call_signal_handler ()) - continue; - len = (size_t) -1; - set_errno (EINTR); - break; - case WAIT_OBJECT_0 + 2: - pthread::static_cancel_self (); - break; case WAIT_TIMEOUT: len = (size_t) -1; set_errno (EAGAIN); @@ -163,25 +164,3 @@ fhandler_windows::ioctl (unsigned int cmd, void *val) } return 0; } - -void -fhandler_windows::set_close_on_exec (bool val) -{ - if (get_handle ()) - fhandler_base::set_close_on_exec (val); - else - fhandler_base::close_on_exec (val); - void *h = hWnd_; - if (h) - set_no_inheritance (h, val); -} - -void -fhandler_windows::fixup_after_fork (HANDLE parent) -{ - if (get_handle ()) - fhandler_base::fixup_after_fork (parent); - void *h = hWnd_; - if (h) - fork_fixup (parent, h, "hWnd_"); -} |