From c5574d0e6da0f1586187ad37ffb92c064c199993 Mon Sep 17 00:00:00 2001 From: corinna Date: Wed, 25 Oct 2000 08:47:23 +0000 Subject: [PATCH] * fhandler.cc (fhandler_base::fcntl): Treat O_NONBLOCK and OLD_O_NDELAY as exactly the same. If one is set, both are set. * net.cc (fhandler_socket::fcntl): Ditto. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/fhandler.cc | 9 +++++++-- winsup/cygwin/net.cc | 23 +++++++++++++++-------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fdfe29358f..c0ff45808a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +Wed Oct 25 10:43:00 2000 Corinna Vinschen + + * fhandler.cc (fhandler_base::fcntl): Treat O_NONBLOCK and OLD_O_NDELAY + as exactly the same. If one is set, both are set. + * net.cc (fhandler_socket::fcntl): Ditto. + Tue Oct 24 23:58:35 2000 Christopher Faylor * dcrt0.cc (do_exit): Remove debugging statement. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index abeef9e55c..811b03888d 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1021,12 +1021,17 @@ int fhandler_base::fcntl (int cmd, void *arg) * Each other flag will be ignored. * Since O_ASYNC isn't defined in fcntl.h it's currently * ignored as well. - * There's no functionality at all, so... */ const int allowed_flags = O_APPEND | O_NONBLOCK | OLD_O_NDELAY; + /* Care for the old O_NDELAY flag. If one of the flags is set, + both flags are set. */ + int new_flags = (int) arg; + if (new_flags & (O_NONBLOCK | OLD_O_NDELAY)) + new_flags |= O_NONBLOCK | OLD_O_NDELAY; + int flags = get_flags () & ~allowed_flags; - set_flags (flags | ((int)arg & allowed_flags)); + set_flags (flags | (new_flags & allowed_flags)); } res = 0; break; diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 10153f417b..d5e358c101 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1988,15 +1988,22 @@ fhandler_socket::fcntl (int cmd, void *arg) switch (cmd) { case F_SETFL: - request = ((int) arg & O_NONBLOCK) ? 1 : 0; - current = (get_flags () & O_NONBLOCK) ? 1 : 0; - if (request != current && (res = ioctl (FIONBIO, &request))) + { + /* Care for the old O_NDELAY flag. If one of the flags is set, + both flags are set. */ + int new_flags = (int) arg; + if (new_flags & (O_NONBLOCK | OLD_O_NDELAY)) + new_flags |= O_NONBLOCK | OLD_O_NDELAY; + request = (new_flags & O_NONBLOCK) ? 1 : 0; + current = (get_flags () & O_NONBLOCK) ? 1 : 0; + if (request != current && (res = ioctl (FIONBIO, &request))) + break; + if (request) + set_flags (get_flags () | O_NONBLOCK | OLD_O_NDELAY); + else + set_flags (get_flags () & ~(O_NONBLOCK | OLD_O_NDELAY)); break; - if (request) - set_flags (get_flags () | O_NONBLOCK); - else - set_flags (get_flags () & ~O_NONBLOCK); - break; + } default: res = fhandler_base::fcntl (cmd, arg); break; -- 2.11.0