aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-08-15 07:49:15 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-08-15 07:49:15 +0000
commit5fd12fb0cc61778a909bdae69d8f61d644e135ba (patch)
treeca8096e1a0fb1acc80061ecca2d966269a75b802 /winsup
parentda3ea61edda86f0f1c3176b5b1ee30265c5ec1a3 (diff)
downloadnewlib-5fd12fb0cc61778a909bdae69d8f61d644e135ba.zip
newlib-5fd12fb0cc61778a909bdae69d8f61d644e135ba.tar.gz
newlib-5fd12fb0cc61778a909bdae69d8f61d644e135ba.tar.bz2
* fhandler.cc (fhandler_base::is_nonblocking): New method.
(fhandler_base::set_nonblocking): Ditto. * fhandler.h (fhandler_base): Declare new methods `is_nonblocking' and `set_nonblocking'. * fhandler_socket.cc (fhandler_socket::ioctl): Use `set_nonblocking'. * fhandler_tty.cc (fhandler_pty_master::process_slave_output): Use `is_nonblocking'. (fhandler_tty_slave::read): Ditto. (fhandler_tty_slave::ioctl): Use `set_nonblocking'. (fhandler_pty_master::ioctl): Ditto. * net.cc (cygwin_sendto): Fallback to winsock 1 functionality in case of nonblocking IO. (cygwin_recvfrom): Ditto. (cygwin_recv): Ditto. (cygwin_send): Ditto. * syscalls.cc (_read): Use `is_nonblocking'.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog19
-rw-r--r--winsup/cygwin/fhandler.cc14
-rw-r--r--winsup/cygwin/fhandler.h3
-rw-r--r--winsup/cygwin/fhandler_socket.cc4
-rw-r--r--winsup/cygwin/fhandler_tty.cc19
-rw-r--r--winsup/cygwin/net.cc9
-rw-r--r--winsup/cygwin/syscalls.cc2
7 files changed, 46 insertions, 24 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 0c9e9e7..16874fe 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,22 @@
+Wed Aug 15 9:42:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * fhandler.cc (fhandler_base::is_nonblocking): New method.
+ (fhandler_base::set_nonblocking): Ditto.
+ * fhandler.h (fhandler_base): Declare new methods `is_nonblocking' and
+ `set_nonblocking'.
+ * fhandler_socket.cc (fhandler_socket::ioctl): Use `set_nonblocking'.
+ * fhandler_tty.cc (fhandler_pty_master::process_slave_output):
+ Use `is_nonblocking'.
+ (fhandler_tty_slave::read): Ditto.
+ (fhandler_tty_slave::ioctl): Use `set_nonblocking'.
+ (fhandler_pty_master::ioctl): Ditto.
+ * net.cc (cygwin_sendto): Fallback to winsock 1 functionality
+ in case of nonblocking IO.
+ (cygwin_recvfrom): Ditto.
+ (cygwin_recv): Ditto.
+ (cygwin_send): Ditto.
+ * syscalls.cc (_read): Use `is_nonblocking'.
+
Tue Aug 14 11:05:26 2001 Christopher Faylor <cgf@cygnus.com>
* include/cygwin/version.h: Bump API version.
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index c4af734..86c6b4d 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1572,3 +1572,17 @@ fhandler_base::fixup_after_fork (HANDLE parent)
debug_printf ("inheriting '%s' from parent", get_name ());
fork_fixup (parent, io_handle, "io_handle");
}
+
+int
+fhandler_base::is_nonblocking ()
+{
+ return (openflags & O_NONBLOCK_MASK) != 0;
+}
+
+void
+fhandler_base::set_nonblocking (int yes)
+{
+ int current = openflags & O_NONBLOCK_MASK;
+ int new_flags = yes ? (!current ? O_NONBLOCK : current) : 0;
+ openflags = (openflags & ~O_NONBLOCK_MASK) | new_flags;
+}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index a46f7d9..dd1df29 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -207,6 +207,9 @@ public:
int get_flags () { return openflags; }
void set_flags (int x) { openflags = x; }
+ int is_nonblocking ();
+ void set_nonblocking (int yes);
+
int get_w_binary () { return FHISSETF (WBINARY); }
int get_r_binary () { return FHISSETF (RBINARY); }
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 7c1be07..9e63489 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -406,9 +406,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (*(int *) p && get_async ())
WSAAsyncSelect (get_socket (), gethwnd (), WM_ASYNCIO, ASYNC_MASK);
- int current = get_flags () & O_NONBLOCK_MASK;
- int new_flags = *(int *) p ? (!current ? O_NONBLOCK : current) : 0;
- set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
+ set_nonblocking (*(int *) p);
}
break;
}
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 942f31d..5d51ca0 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -25,8 +25,6 @@ details. */
#include "pinfo.h"
#include "cygheap.h"
#include "shared_info.h"
-#include "cygwin/version.h"
-#include "perprocess.h"
/* Tty master stuff */
@@ -297,7 +295,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on
break;
if (hit_eof ())
goto out;
- if (n == 0 && (get_flags () & O_NONBLOCK_MASK) != 0)
+ if (n == 0 && is_nonblocking ())
{
set_errno (EAGAIN);
rc = -1;
@@ -748,8 +746,7 @@ fhandler_tty_slave::read (void *ptr, size_t len)
termios_printf ("saw EOF");
break;
}
- if (get_ttyp ()->ti.c_lflag & ICANON ||
- get_flags () & O_NONBLOCK_MASK)
+ if (get_ttyp ()->ti.c_lflag & ICANON || is_nonblocking ())
break;
if (totalread >= vmin && (vmin > 0 || totalread > 0))
break;
@@ -915,11 +912,7 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg)
case TIOCSWINSZ:
break;
case FIONBIO:
- {
- int current = get_flags () & O_NONBLOCK_MASK;
- int new_flags = *(int *) arg ? (!current ? O_NONBLOCK : current) : 0;
- set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
- }
+ set_nonblocking (*(int *) arg);
goto out;
default:
set_errno (EINVAL);
@@ -1099,11 +1092,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
_kill (-get_ttyp ()->getpgid (), SIGWINCH);
break;
case FIONBIO:
- {
- int current = get_flags () & O_NONBLOCK_MASK;
- int new_flags = *(int *) arg ? (!current ? O_NONBLOCK : current) : 0;
- set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags);
- }
+ set_nonblocking (*(int *) arg);
break;
default:
set_errno (EINVAL);
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc
index be68f42..db7a949 100644
--- a/winsup/cygwin/net.cc
+++ b/winsup/cygwin/net.cc
@@ -25,7 +25,6 @@ details. */
#define USE_SYS_TYPES_FD_SET
#include <winsock2.h>
#include "cygerrno.h"
-#include "perprocess.h"
#include "security.h"
#include "fhandler.h"
#include "path.h"
@@ -512,7 +511,7 @@ cygwin_sendto (int fd,
if (get_inet_addr (to, tolen, &sin, &tolen) == 0)
return -1;
- if (!(ovr = wsock_evt.prepare ()))
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 sendto call");
if ((res = sendto (h->get_socket (), (const char *) buf, len, flags,
@@ -558,7 +557,7 @@ cygwin_recvfrom (int fd,
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
sigframe thisframe (mainthread);
- if (!(ovr = wsock_evt.prepare ()))
+ if (h->is_nonblocking () ||!(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 recvfrom call");
if ((res = recvfrom (h->get_socket (), buf, len, flags, from, fromlen))
@@ -1208,7 +1207,7 @@ cygwin_recv (int fd, void *buf, int len, unsigned int flags)
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
sigframe thisframe (mainthread);
- if (!(ovr = wsock_evt.prepare ()))
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 recv call");
if ((res = recv (h->get_socket (), (char *) buf, len, flags))
@@ -1249,7 +1248,7 @@ cygwin_send (int fd, const void *buf, int len, unsigned int flags)
fhandler_socket *h = (fhandler_socket *) cygheap->fdtab[fd];
sigframe thisframe (mainthread);
- if (!(ovr = wsock_evt.prepare ()))
+ if (h->is_nonblocking () || !(ovr = wsock_evt.prepare ()))
{
debug_printf ("Fallback to winsock 1 send call");
if ((res = send (h->get_socket (), (const char *) buf, len, flags))
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index f3fecf1..9fbd7f8 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -271,7 +271,7 @@ _read (int fd, void *ptr, size_t len)
// set_sig_errno (0);
fh = cygheap->fdtab[fd];
- DWORD wait = (fh->get_flags () & O_NONBLOCK_MASK) ? 0 : INFINITE;
+ DWORD wait = fh->is_nonblocking () ? 0 : INFINITE;
/* Could block, so let user know we at least got here. */
syscall_printf ("read (%d, %p, %d) %sblocking, sigcatchers %d", fd, ptr, len, wait ? "" : "non", sigcatchers);