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-11-02 00:15:53 +0300
committerChristopher Faylor <me@cgf.cx>2001-11-02 00:15:53 +0300
commit1229d4f4eeec60957897cbf851adff5f61ab4df5 (patch)
tree070d8a75c184f67cf5aaade88b4903aa8d2743cb
parent5cf6708ef4559248ba751adc349af475e654be2a (diff)
* dtable.cc (dtable::build_fhandler): Issue internal error on unknown device.
* fhandler.cc (fhandler_base::close): Show both name and handle in debugging output. * fhandler.h (fhandler_base::get_guard): New virtual method. (fhandler_pipe::get_guard): New method. (fhandler_socket::ready_for_read): Delete declaration. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (struct select_record::peek): Declare new method. * select.cc (MAKEready): Delete. (peek_pipe): Use get_guard method to retrieve potential guard mutex handle. (fhandler_base::ready_for_read): Rewrite as generic ready-for-read handler. Should only be called for "slow" devices. (fhandler_socket::ready_for_read): Delete definition. (fhandler_pipe::ready_for_read): Ditto. (fhandler_serial::ready_for_read): Ditto. (fhandler_console::ready_for_read): Ditto. (fhandler_tty_common::ready_for_read): Ditto. (fhandler_windows::ready_for_read): Ditto. (fhandler_pipe::select_read): Fill in new peek record in select_record structure. (fhandler_console::select_read): Ditto. (fhandler_tty_common::select_read): Ditto. (fhandler_serial::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_socket::select_read): Ditto. (fhandler_tty_slave::ready_for_read): Check for tty not open. Set errnos appropriately. * syscalls.cc (_read): Allow ready_for_read to set errno. * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it is initializing. * sigproc.cc (getsem): Adjust wait for process to initialize downward to avoid huge waits.
-rw-r--r--winsup/cygwin/ChangeLog43
-rw-r--r--winsup/cygwin/dtable.cc9
-rw-r--r--winsup/cygwin/fhandler.cc2
-rw-r--r--winsup/cygwin/fhandler.h85
-rw-r--r--winsup/cygwin/pinfo.cc3
-rw-r--r--winsup/cygwin/pipe.cc3
-rw-r--r--winsup/cygwin/select.cc114
-rw-r--r--winsup/cygwin/sigproc.cc2
-rw-r--r--winsup/cygwin/syscalls.cc4
9 files changed, 146 insertions, 119 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index de9794448..76f437f1b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,46 @@
+2001-11-01 Christopher Faylor <cgf@redhat.com>
+
+ * dtable.cc (dtable::build_fhandler): Issue internal error on unknown
+ device.
+ * fhandler.cc (fhandler_base::close): Show both name and handle in
+ debugging output.
+
+ * fhandler.h (fhandler_base::get_guard): New virtual method.
+ (fhandler_pipe::get_guard): New method.
+ (fhandler_socket::ready_for_read): Delete declaration.
+ (fhandler_pipe::ready_for_read): Ditto.
+ (fhandler_serial::ready_for_read): Ditto.
+ (fhandler_console::ready_for_read): Ditto.
+ (fhandler_tty_common::ready_for_read): Ditto.
+ (fhandler_windows::ready_for_read): Ditto.
+ (struct select_record::peek): Declare new method.
+ * select.cc (MAKEready): Delete.
+ (peek_pipe): Use get_guard method to retrieve potential guard mutex
+ handle.
+ (fhandler_base::ready_for_read): Rewrite as generic ready-for-read
+ handler. Should only be called for "slow" devices.
+ (fhandler_socket::ready_for_read): Delete definition.
+ (fhandler_pipe::ready_for_read): Ditto.
+ (fhandler_serial::ready_for_read): Ditto.
+ (fhandler_console::ready_for_read): Ditto.
+ (fhandler_tty_common::ready_for_read): Ditto.
+ (fhandler_windows::ready_for_read): Ditto.
+ (fhandler_pipe::select_read): Fill in new peek record in select_record
+ structure.
+ (fhandler_console::select_read): Ditto.
+ (fhandler_tty_common::select_read): Ditto.
+ (fhandler_serial::select_read): Ditto.
+ (fhandler_socket::select_read): Ditto.
+ (fhandler_socket::select_read): Ditto.
+ (fhandler_tty_slave::ready_for_read): Check for tty not open. Set
+ errnos appropriately.
+ * syscalls.cc (_read): Allow ready_for_read to set errno.
+
+ * pinfo.cc (pinfo::init): Return spawn/NO_WAIT process as valid if it
+ is initializing.
+ * sigproc.cc (getsem): Adjust wait for process to initialize downward
+ to avoid huge waits.
+
2001-10-31 Christopher Faylor <cgf@redhat.com>
* environ.cc: Set reset_com to false to mimic linux behavior more
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index b929b169e..e3b191788 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -325,14 +325,11 @@ dtable::build_fhandler (int fd, DWORD dev, const char *name, int unit)
fh = cnew (fhandler_dev_dsp) ();
break;
default:
- {
- /* FIXME - this could recurse forever */
- path_conv pc;
- return build_fhandler_from_name (fd, name, NULL, pc);
- }
+ system_printf ("internal error -- unknown device - %p", dev);
+ fh = NULL;
}
- debug_printf ("%s - fd %d, fh %p", fh->get_name () ?: "", fd, fh);
+ debug_printf ("%s - fd %d, fh %p", fd, fh);
return fd >= 0 ? (fds[fd] = fh) : fh;
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 9617790e2..1db9a7b03 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -784,7 +784,7 @@ fhandler_base::close ()
{
int res = -1;
- syscall_printf ("handle %p", get_handle());
+ syscall_printf ("closing '%s' handle %p", get_name (), get_handle());
if (CloseHandle (get_handle()))
res = 0;
else
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index 7307a8fdc..9559a1468 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -157,15 +157,15 @@ enum executable_states
class fhandler_base
{
-protected:
+ protected:
DWORD status;
-private:
+ private:
int access;
HANDLE io_handle;
unsigned long namehash; /* hashed filename, used as inode num */
-protected:
+ protected:
/* Full unix path name of this file */
/* File open flags from open () and fcntl () calls */
int openflags;
@@ -180,7 +180,7 @@ protected:
char *win32_path_name;
DWORD open_status;
-public:
+ public:
void set_name (const char * unix_path, const char * win32_path = NULL,
int unit = 0);
@@ -371,17 +371,18 @@ public:
rabuf = NULL;
}
void operator delete (void *);
+ HANDLE get_guard () const {return NULL;}
};
class fhandler_socket: public fhandler_base
{
-private:
+ private:
int addr_family;
int connect_secret [4];
HANDLE secret_event;
struct _WSAPROTOCOL_INFOA *prot_info_ptr;
-public:
+ public:
fhandler_socket ();
~fhandler_socket ();
int get_socket () { return (int) get_handle(); }
@@ -410,7 +411,6 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
int get_addr_family () {return addr_family;}
void set_addr_family (int af) {addr_family = af;}
void set_connect_secret ();
@@ -428,13 +428,12 @@ class fhandler_pipe: public fhandler_base
HANDLE writepipe_exists;
DWORD orig_pid;
unsigned id;
-public:
+ public:
fhandler_pipe (DWORD devtype = FH_PIPE);
off_t lseek (off_t offset, int whence);
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
void set_close_on_exec (int val);
int __stdcall read (void *ptr, size_t len) __attribute__ ((regparm (3)));
int close ();
@@ -443,11 +442,12 @@ public:
void fixup_after_fork (HANDLE);
bool hit_eof ();
friend int make_pipe (int fildes[2], unsigned int psize, int mode);
+ HANDLE get_guard () const {return guard;}
};
class fhandler_dev_raw: public fhandler_base
{
-protected:
+ protected:
char *devbuf;
size_t devbufsiz;
size_t devbufstart;
@@ -470,7 +470,7 @@ protected:
fhandler_dev_raw (DWORD dev, int unit);
-public:
+ public:
~fhandler_dev_raw (void);
int get_unit () { return unit; }
@@ -491,11 +491,11 @@ public:
class fhandler_dev_floppy: public fhandler_dev_raw
{
-protected:
+ protected:
virtual int is_eom (int win_error);
virtual int is_eof (int win_error);
-public:
+ public:
fhandler_dev_floppy (int unit);
virtual int open (path_conv *, int flags, mode_t mode = 0);
@@ -512,13 +512,13 @@ class fhandler_dev_tape: public fhandler_dev_raw
bool is_rewind_device () { return get_unit () < 128; }
-protected:
+ protected:
virtual void clear (void);
virtual int is_eom (int win_error);
virtual int is_eof (int win_error);
-public:
+ public:
fhandler_dev_tape (int unit);
int open (path_conv *, int flags, mode_t mode = 0);
@@ -532,7 +532,7 @@ public:
int ioctl (unsigned int cmd, void *buf);
-private:
+ private:
int tape_write_marks (int marktype, DWORD len);
int tape_get_pos (unsigned long *ret);
int tape_set_pos (int mode, long count, BOOLEAN sfm_func = FALSE);
@@ -549,7 +549,7 @@ private:
class fhandler_disk_file: public fhandler_base
{
-public:
+ public:
fhandler_disk_file ();
int open (path_conv * real_path, int flags, mode_t mode);
@@ -568,12 +568,12 @@ public:
class fhandler_serial: public fhandler_base
{
-private:
+ private:
unsigned int vmin_; /* from termios */
unsigned int vtime_; /* from termios */
pid_t pgrp_;
-public:
+ public:
int overlapped_armed;
OVERLAPPED io_status;
@@ -607,7 +607,6 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
#define acquire_output_mutex(ms) \
@@ -620,11 +619,11 @@ class tty;
class tty_min;
class fhandler_termios: public fhandler_base
{
-protected:
+ protected:
HANDLE output_handle;
virtual void doecho (const void *, DWORD) {};
virtual int accept_input () {return 1;};
-public:
+ public:
tty_min *tc;
fhandler_termios (DWORD dev, int unit = 0) :
fhandler_base (dev, unit)
@@ -667,7 +666,7 @@ enum ansi_intensity
/* This is a input and output console handle */
class fhandler_console: public fhandler_termios
{
-private:
+ private:
WORD default_color, underline_color, dim_color;
@@ -737,7 +736,7 @@ private:
int input_tcsetattr (int a, const struct termios *t);
void set_cursor_maybe ();
-public:
+ public:
fhandler_console ();
@@ -764,7 +763,6 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
void fixup_after_exec (HANDLE);
void set_close_on_exec (int val);
void fixup_after_fork (HANDLE parent);
@@ -773,7 +771,7 @@ public:
class fhandler_tty_common: public fhandler_termios
{
-public:
+ public:
fhandler_tty_common (DWORD dev, int unit = 0)
: fhandler_termios (dev, unit), output_done_event (NULL),
ioctl_request_event (NULL), ioctl_done_event (NULL), output_mutex (NULL),
@@ -806,12 +804,11 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
class fhandler_tty_slave: public fhandler_tty_common
{
-public:
+ public:
/* Constructor */
fhandler_tty_slave ();
fhandler_tty_slave (int);
@@ -834,7 +831,7 @@ public:
class fhandler_pty_master: public fhandler_tty_common
{
int pktmode; // non-zero if pty in a packet mode.
-public:
+ public:
int need_nl; // Next read should start with \n
/* Constructor */
@@ -862,7 +859,7 @@ public:
class fhandler_tty_master: public fhandler_pty_master
{
-public:
+ public:
/* Constructor */
fhandler_console *console; // device handler to perform real i/o.
HANDLE hThread; // process_output thread handle.
@@ -876,7 +873,7 @@ public:
class fhandler_dev_null: public fhandler_base
{
-public:
+ public:
fhandler_dev_null ();
void dump ();
@@ -887,7 +884,7 @@ public:
class fhandler_dev_zero: public fhandler_base
{
-public:
+ public:
fhandler_dev_zero ();
int open (path_conv *, int flags, mode_t mode = 0);
int write (const void *ptr, size_t len);
@@ -900,7 +897,7 @@ public:
class fhandler_dev_random: public fhandler_base
{
-protected:
+ protected:
int unit;
HCRYPTPROV crypt_prov;
long pseudo;
@@ -909,7 +906,7 @@ protected:
int pseudo_write (const void *ptr, size_t len);
int pseudo_read (void *ptr, size_t len);
-public:
+ public:
fhandler_dev_random (int unit);
int get_unit () { return unit; }
int open (path_conv *, int flags, mode_t mode = 0);
@@ -924,12 +921,12 @@ public:
class fhandler_dev_mem: public fhandler_base
{
-protected:
+ protected:
int unit;
DWORD mem_size;
DWORD pos;
-public:
+ public:
fhandler_dev_mem (int unit);
~fhandler_dev_mem (void);
@@ -952,7 +949,7 @@ public:
class fhandler_dev_clipboard: public fhandler_base
{
-public:
+ public:
fhandler_dev_clipboard ();
int is_windows (void) { return 1; }
int open (path_conv *, int flags, mode_t mode = 0);
@@ -965,7 +962,7 @@ public:
void dump ();
-private:
+ private:
off_t pos;
void *membuffer;
size_t msize;
@@ -974,10 +971,10 @@ private:
class fhandler_windows: public fhandler_base
{
-private:
+ private:
HWND hWnd_; // the window whose messages are to be retrieved by read() call
int method_; // write method (Post or Send)
-public:
+ public:
fhandler_windows ();
int is_windows (void) { return 1; }
int open (path_conv *, int flags, mode_t mode = 0);
@@ -992,18 +989,17 @@ public:
select_record *select_read (select_record *s);
select_record *select_write (select_record *s);
select_record *select_except (select_record *s);
- int ready_for_read (int fd, DWORD howlong, int ignra);
};
class fhandler_dev_dsp : public fhandler_base
{
-private:
+ private:
int audioformat_;
int audiofreq_;
int audiobits_;
int audiochannels_;
bool setupwav(const char *pData, int nBytes);
-public:
+ public:
fhandler_dev_dsp ();
~fhandler_dev_dsp();
@@ -1055,6 +1051,7 @@ struct select_record
int (*startup) (select_record *me, class select_stuff *stuff);
int (*poll) (select_record *me, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds);
+ int (*peek) (select_record *, int);
int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds,
fd_set *exceptfds);
void (*cleanup) (select_record *me, class select_stuff *stuff);
@@ -1070,7 +1067,7 @@ struct select_record
class select_stuff
{
-public:
+ public:
~select_stuff ();
select_stuff (): always_ready (0), windows_used (0), start (0)
{
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 48b257699..ffd3d4ec6 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -182,7 +182,8 @@ pinfo::init (pid_t n, DWORD flag, HANDLE in_h)
procinfo = (_pinfo *) MapViewOfFile (h, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
ProtectHandle1 (h, pinfo_shared_handle);
- if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR))
+ if ((procinfo->process_state & PID_INITIALIZING) && (flag & PID_NOREDIR)
+ && cygwin_pid (procinfo->dwProcessId) != procinfo->pid)
{
release ();
set_errno (ENOENT);
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index 5809b40f8..fed1add0f 100644
--- a/winsup/cygwin/pipe.cc
+++ b/winsup/cygwin/pipe.cc
@@ -26,7 +26,8 @@ static unsigned pipecount;
static const NO_COPY char pipeid_fmt[] = "stupid_pipe.%u.%u";
fhandler_pipe::fhandler_pipe (DWORD devtype)
- : fhandler_base (devtype), guard (0), writepipe_exists(0), orig_pid (0), id (0)
+ : fhandler_base (devtype), guard (NULL), writepipe_exists(0),
+ orig_pid (0), id (0)
{
}
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 489bca5cc..2b807e388 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -84,24 +84,6 @@ typedef long fd_mask;
#define allocfd_set(n) ((fd_set *) memset (alloca (sizeof_fd_set (n)), 0, sizeof_fd_set (n)))
#define copyfd_set(to, from, n) memcpy (to, from, sizeof_fd_set (n));
-/* Make a fhandler_foo::ready_for_ready method.
- Assumption: The "ready_for_read" methods are called with one level of
- signal blocking. */
-#define MAKEready(what) \
-int \
-fhandler_##what::ready_for_read (int fd, DWORD howlong, int ignra) \
-{ \
- select_record me (this); \
- me.fd = fd; \
- while (select_read (&me) && !me.read_ready && \
- !peek_##what (&me, ignra) && howlong == INFINITE) \
- if (fd >= 0 && cygheap->fdtab.not_open (fd)) \
- break; \
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0) \
- break; \
- return me.read_ready; \
-}
-
#define set_handle_or_return_if_not_open(h, s) \
h = (s)->fh->get_handle (); \
if (cygheap->fdtab.not_open ((s)->fd)) \
@@ -400,13 +382,14 @@ no_verify (select_record *, fd_set *, fd_set *, fd_set *)
}
static int
-peek_pipe (select_record *s, int ignra, HANDLE guard_mutex = NULL)
+peek_pipe (select_record *s, int ignra)
{
int n = 0;
int gotone = 0;
fhandler_base *fh = s->fh;
HANDLE h;
+ HANDLE guard_mutex = s->fh->get_guard ();
set_handle_or_return_if_not_open (h, s);
/* Don't perform complicated tests if we don't need to. */
@@ -499,21 +482,6 @@ poll_pipe (select_record *me, fd_set *readfds, fd_set *writefds,
0;
}
-int
-fhandler_pipe::ready_for_read (int fd, DWORD howlong, int ignra)
-{
- select_record me (this);
- me.fd = fd;
- (void) select_read (&me);
- while (!peek_pipe (&me, ignra, guard) && howlong == INFINITE)
- if (fd >= 0 && cygheap->fdtab.not_open (fd))
- break;
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
- break;
- select_printf ("returning %d", me.read_ready);
- return me.read_ready;
-}
-
static int start_thread_pipe (select_record *me, select_stuff *stuff);
struct pipeinf
@@ -596,6 +564,7 @@ fhandler_pipe::select_read (select_record *s)
s = new select_record;
s->startup = start_thread_pipe;
s->poll = poll_pipe;
+ s->peek = peek_pipe;
s->verify = verify_ok;
s->read_selected = TRUE;
s->cleanup = pipe_cleanup;
@@ -693,8 +662,6 @@ poll_console (select_record *me, fd_set *readfds, fd_set *writefds,
0;
}
-MAKEready (console)
-
select_record *
fhandler_console::select_read (select_record *s)
{
@@ -707,6 +674,7 @@ fhandler_console::select_read (select_record *s)
set_cursor_maybe ();
}
+ s->peek = peek_console;
s->h = get_handle ();
s->read_selected = TRUE;
return s;
@@ -745,21 +713,6 @@ fhandler_console::select_except (select_record *s)
return s;
}
-int
-fhandler_tty_common::ready_for_read (int fd, DWORD howlong, int ignra)
-{
- select_record me (this);
- me.fd = fd;
- (void) select_read (&me);
- while (!peek_pipe (&me, ignra) && howlong == INFINITE)
- if (fd >= 0 && cygheap->fdtab.not_open (fd))
- break;
- else if (WaitForSingleObject (signal_arrived, 10) == WAIT_OBJECT_0)
- break;
- select_printf ("returning %d", me.read_ready);
- return me.read_ready;
-}
-
select_record *
fhandler_tty_common::select_read (select_record *s)
{
@@ -795,6 +748,7 @@ fhandler_tty_slave::select_read (select_record *s)
s->h = input_available_event;
s->startup = no_startup;
s->poll = poll_pipe;
+ s->peek = peek_pipe;
s->verify = verify_tty_slave;
s->read_selected = TRUE;
s->cleanup = NULL;
@@ -805,6 +759,11 @@ int
fhandler_tty_slave::ready_for_read (int fd, DWORD howlong, int ignra)
{
HANDLE w4[2];
+ if (!cygheap->fdtab.not_open (fd))
+ {
+ set_errno (EBADF);
+ return 1;
+ }
if (!ignra && get_readahead_valid ())
{
select_printf ("readahead");
@@ -814,13 +773,18 @@ fhandler_tty_slave::ready_for_read (int fd, DWORD howlong, int ignra)
w4[1] = input_available_event;
switch (WaitForMultipleObjects (2, w4, FALSE, howlong))
{
+ case WAIT_OBJECT_0:
+ set_errno (EINTR);
+ return 0;
case WAIT_OBJECT_0 + 1:
return 1;
case WAIT_FAILED:
select_printf ("wait failed %E");
- case WAIT_OBJECT_0:
- case WAIT_TIMEOUT:
+ set_errno (EINVAL); /* FIXME: correct errno? */
+ return 0;
default:
+ if (!howlong)
+ set_errno (EAGAIN);
return 0;
}
}
@@ -1058,8 +1022,6 @@ poll_serial (select_record *me, fd_set *readfds, fd_set *writefds,
0;
}
-MAKEready (serial)
-
select_record *
fhandler_serial::select_read (select_record *s)
{
@@ -1071,6 +1033,7 @@ fhandler_serial::select_read (select_record *s)
s->verify = verify_ok;
s->cleanup = serial_cleanup;
}
+ s->peek = peek_serial;
s->read_selected = TRUE;
return s;
}
@@ -1107,9 +1070,40 @@ fhandler_serial::select_except (select_record *s)
}
int
-fhandler_base::ready_for_read (int, DWORD, int)
+fhandler_base::ready_for_read (int fd, DWORD howlong, int ignra)
{
- return 1;
+ int avail = 0;
+ select_record me (this);
+ me.fd = fd;
+ while (!avail)
+ {
+ (void) select_read (&me);
+ avail = me.read_ready ?: me.peek (&me, ignra);
+
+ if (fd >= 0 && cygheap->fdtab.not_open (fd))
+ {
+ set_errno (EBADF);
+ avail = 0;
+ break;
+ }
+
+ if (howlong != INFINITE)
+ {
+ if (!avail)
+ set_errno (EAGAIN);
+ break;
+ }
+
+ if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
+ {
+ set_errno (EINTR);
+ avail = 0;
+ break;
+ }
+ }
+
+ select_printf ("read_ready %d, avail %d", me.read_ready, avail);
+ return avail;
}
select_record *
@@ -1226,8 +1220,6 @@ poll_socket (select_record *me, fd_set *readfds, fd_set *writefds,
0;
}
-MAKEready (socket)
-
static int start_thread_socket (select_record *, select_stuff *);
static DWORD WINAPI
@@ -1406,6 +1398,7 @@ fhandler_socket::select_read (select_record *s)
s->verify = verify_true;
s->cleanup = socket_cleanup;
}
+ s->peek = peek_socket;
s->read_ready = saw_shutdown_read ();
s->read_selected = TRUE;
return s;
@@ -1475,8 +1468,6 @@ poll_windows (select_record *me, fd_set *readfds, fd_set *writefds,
0;
}
-MAKEready (windows)
-
select_record *
fhandler_windows::select_read (select_record *s)
{
@@ -1487,6 +1478,7 @@ fhandler_windows::select_read (select_record *s)
s->poll = poll_windows;
s->verify = poll_windows;
}
+ s->peek = peek_windows;
s->h = get_handle ();
s->read_selected = TRUE;
s->h = get_handle ();
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 11b04ec4f..fd5008abd 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -899,7 +899,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
set_errno (ESRCH);
return NULL;
}
- int wait = 10000;
+ int wait = 1000;
sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
ISSTATE (p, PID_INITIALIZING));
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 57eb51cd2..164e3242c 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -314,10 +314,6 @@ _read (int fd, void *ptr, size_t len)
debug_printf ("non-interruptible read\n");
else if (!cfd->ready_for_read (fd, wait, 0))
{
- if (!wait)
- set_sig_errno (EAGAIN); /* Don't really need 'set_sig_errno' here, but... */
- else
- set_sig_errno (EINTR);
res = -1;
goto out;
}