Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-08-07 04:01:42 +0400
committerChristopher Faylor <me@cgf.cx>2001-08-07 04:01:42 +0400
commit96a3f4ae6884bbf0c2e96d8ab332c3fad85613bf (patch)
tree68d8717111e5f046c192a1dd0f0dbd2481367f20 /winsup/cygwin/fhandler_socket.cc
parent386abb05d958a410c90cd4b7ea25187c7f6f1fbc (diff)
* cygheap.cc (cygheap_root::set): Avoid treating '/' specially.
* fhandler.cc (fhandler_base::fcntl): Only set specific O_NDELAY style flag passed in from application. * fhandler_socket.cc (fhandler_socket::fcntl): Ditto. * fhandler.h: Set constant for future use. * winsup.h: Define OLD_O_NDELAY only for old programs. * include/cygwin/version.h: Define CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK.
Diffstat (limited to 'winsup/cygwin/fhandler_socket.cc')
-rw-r--r--winsup/cygwin/fhandler_socket.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 13cbe9f49..185843b53 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -24,6 +24,8 @@
#include <winsock2.h>
#include "cygerrno.h"
#include "security.h"
+#include "cygwin/version.h"
+#include "perprocess.h"
#include "fhandler.h"
#include "dtable.h"
#include "cygheap.h"
@@ -412,17 +414,18 @@ fhandler_socket::fcntl (int cmd, void *arg)
{
/* 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)))
+ const int allowed_flags = O_NONBLOCK | OLD_O_NDELAY;
+
+ /* Carefully test for the O_NONBLOCK or deprecated OLD_O_NDELAY flag.
+ Set only the flag that has been passed in. If both are set, just
+ record O_NONBLOCK. */
+ int new_flags = (int) arg & allowed_flags;
+ if ((new_flags & OLD_O_NDELAY) && (new_flags & O_NONBLOCK))
+ new_flags = O_NONBLOCK;
+ current = get_flags () & allowed_flags;
+ if (!!current != !!new_flags && (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));
+ set_flags ((get_flags () & ~allowed_flags) | new_flags);
break;
}
default: