GNOME Bugzilla – Bug 57690
is_readable and is_writeable flags not set when creating iochannels under win32
Last modified: 2011-02-18 15:55:24 UTC
The flags is_readable and is_writeable are not set when creating a new GIOChannel under win32. This breaks most of the new GIOChannel API, but does not cause a problem with the old API.
At 09:39 23.07.01 -0700, Ron Steinke wrote: >Hans, > Looking at you implementation of g_io_channel_win32_new_fd(), >you use fstat() to determine whether to set is_readable and is_writeable. >Under UNIX, fstat() just returns file permissions, Maybe the same for win32 ... >and you need to >use fcntl() to determine whether the file was opened for reading, >writing, or both. Is the same true for win32? > ... but there is no fcntl() in the msvc runtime and I even can't find a respective function in the Win32 Api. So relying on correcly set flags may introduce a serious portability issue. Anyone proofing that my interpretation is wrong is welcome, Hans
One possibility might be to try to read/write zero bytes. Maybe (and that is a big maybe) Win32 returns success if the file handle is readable/writeable? DOes a zero byte read from a pipe hang? There presumably are also 9x/NT/2k differences...
Moving open 2.0.0 Win32 bugs to 2.0.1 milestone.
Moving 2.0.1 Win32 bugs to 2.0.2 milestone.
At least read() and write() in the Microsoft C library return right away if reading/writing zero bytes. But will have to check what the Win32 ReadFile() and WriteFile() do.
Yup, ReadFile() and WriteFile() of zero bytes can be used to check if a file HANDLE is readable/writeable. At least for disk files. For pipes, PeekNamedPipe() can be used to check for readability. For console devices, ReadFile() even of zero bytes seems to block.
Fix applied to HEAD. Reopen if there still are problems.