2000-02-18 03:38:33 +08:00
|
|
|
/* select.cc
|
|
|
|
|
|
|
|
This file is part of Cygwin.
|
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2004-10-11 10:21:31 +08:00
|
|
|
/* The following line means that the BSD socket definitions for
|
|
|
|
fd_set, FD_ISSET etc. are used in this file. */
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN_NET__
|
|
|
|
|
2000-08-03 00:28:18 +08:00
|
|
|
#include "winsup.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
#include <stdlib.h>
|
2009-07-06 23:42:01 +08:00
|
|
|
#include <sys/param.h>
|
2008-05-31 01:56:37 +08:00
|
|
|
#include "ntdll.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-03-21 03:50:28 +08:00
|
|
|
#define USE_SYS_TYPES_FD_SET
|
2011-07-29 20:47:54 +08:00
|
|
|
#include <winsock2.h>
|
2012-07-06 21:52:19 +08:00
|
|
|
#include <netdb.h>
|
2000-08-22 11:58:47 +08:00
|
|
|
#include "cygerrno.h"
|
2001-07-27 03:22:24 +08:00
|
|
|
#include "security.h"
|
2001-10-01 12:10:07 +08:00
|
|
|
#include "path.h"
|
* devices.cc: New file.
* devices.gperf: New file.
* devices.shilka: New file.
* cygwin-gperf: New file.
* cygwin-shilka: New file.
* fhandler_fifo.cc: New file.
* fhandler_nodevice.cc : New file. Reorganize headers so that path.h precedes
fhandler.h throughout. Remove device argument and unit arguments from fhandler
constructors throughout. Remove pc arguments to fhandler functions and use
internal pc element instead, throughout. Use dev element in pc throughout.
Use major/minor elements rather than units and device numbers previously in
fhandler class. Use correct methods for fhandler file names rather than
directly accessing file name variables, throughout.
* Makefile.in (DLL_OFILES): Add devices.o, fhandler_fifo.o
* dcrt0.cc (dll_crt0_1): Call device::init.
* devices.h: Renumber devices based on more Linux-like major/minor numbers.
Add more devices. Declare standard device storage.
(device): Declare struct.
* dir.cc (opendir): Use new 'build_fh_name' to construct a fhandler_* type.
* dtable.cc (dtable::get_debugger_info): Ditto.
(cygwin_attach_handle_to_fd): Ditto.
(dtable::release): Remove special FH_SOCKET case in favor of generic
"need_fixup_before" test.
(dtable::init_std_file_from_handle): Use either build_fh_dev or build_fh_name
to build standard fhandler.
(dtable::build_fh_name): Renamed from dtable::build_fhandler_from_name. Move
out of dtable class. Don't accept a path_conv argument. Just build it here
and pass it to:
(build_fh_pc): Renamed from dtable::build_fhandler. Move out of dtable class.
Use intrinsic device type in path_conv to create new fhandler.
(build_fh_dev): Renamed from dtable::build_fhandler. Move out of dtable class.
Simplify arguments to just take new 'device' type and a name. Just return
pointer to fhandler rather than trying to insert into dtable.
(dtable::dup_worker): Accommodate above build_fh name changes.
(dtable::find_fifo): New (currently broken) function.
(handle_to_fn): Use strechr for efficiency.
* dtable.h: Reflect above build_fh name changes and argument differences.
(fhandler_base *&operator []): Return self rather than copy of self.
* fhandler.cc (fhandler_base::operator =): Use pc element to set normalized
path.
(fhandler_base::set_name): Ditto.
(fhandler_base::raw_read): Use method to access name.
(fhandler_base::write): Correctly use get_output_handle rather than get_handle.
(handler_base::device_access_denied): New function.
(fhandler_base::open): Eliminate pc argument and use pc element of
fhandler_base throughout.
(fhandler_base::fstat): Detect if device is based in filesystem and use
fstat_fs to calculate stat, if so.
(fhandler_base::fhandler_base): Eliminate handling of file names and, instead,
just free appropriate component from pc.
(fhandler_base::opendir): Remove path_conv parameter.
* fhandler.h: Remove all device flags.
(fhandler_base::pc): New element.
(fhandler_base::set_name): Change argument to path_conv.
(fhandler_base::error): New function.
(fhandler_base::exists): New function.
(fhandler_base::pc_binmode): New function.
(fhandler_base::dev): New function.
(fhandler_base::open_fs): New function.
(fhandler_base::fstat_fs): New function.
(fhandler_base::fstat_by_name): New function.
(fhandler_base::fstat_by_handle): New function.
(fhandler_base::isfifo): New function.
(fhandler_base::is_slow): New function.
(fhandler_base::is_auto_device): New function.
(fhandler_base::is_fs_special): New function.
(fhandler_base::device_access_denied): New function.
(fhandler_base::operator DWORD&): New operator.
(fhandler_base::get_name): Return normalized path from pc.
(fhandler_base::get_win32_name): Return windows path from pc.
(fhandler_base::isdevice): Renamed from is_device.
(fhandler_base::get_native_name): Return device format.
(fhandler_fifo): New class.
(fhandler_nodevice): New class.
(select_stuff::device_specific): Remove array.
(select_stuff::device_specific_pipe): New class element.
(select_stuff::device_specific_socket): New class element.
(select_stuff::device_specific_serial): New class element.
(select_stuff::select_stuff): Initialize new elements.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Move to base class
from fhandler_disk_file.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_base::fstat_by_name): Ditto.
(fhandler_disk_file::open): Move most functionality into
fhandler_base::open_fs.
(fhandler_base::open_fs): New function.
(fhandler_disk_file::close): Move most functionality into
fhandler_base::close_fs.
(fhandler_base::close_fs): New function.
* fhandler_mem.cc (fhandler_dev_mem::open): Use device name in debugging
output.
* fhandler_socket.cc (fhandler_socket::set_connect_secret): Copy standard
urandom device into appropriate place.
(fhandler_socket::accept): Reflect change in fdsock return value.
* fhandler_tty.cc: See "throughouts" above.
* net.cc: Accommodate fdsock change throughout.
(fdsock): Return success or failure, accept fd argument and device argument.
* path.cc (symlink_info::major): New element.
(symlink_info::minor): New element.
(symlink_info::parse_device): Declare new function.
(fs_info::update): Accommodate changes in path_conv class.
(path_conv::fillin): Ditto.
(path_conv::return_and_clear_normalized_path): Eliminate.
(path_conv::set_normalized_path): New function.
(path_conv::path_conv): Set info in dev element. Use path_conv methods Check
for FH_FS rather than FH_BAD to indicate when to fill in filesystem stuff.
where appropriate rather than direct access. Use set_normalized_path to set
normalized path.
(windows_device_names): Eliminate.
(get_dev): Ditto.
(get_raw_device_number): Ditto.
(get_device_number): Ditto.
(win32_device_name): Call new device name parser to do most of the heavy
lifting.
(mount_info::conv_to_win32_path): Fill in dev field as appropriate.
(symlink_worker): Handle new device files.
(symlink_info::check): Ditto.
(symlink_info::parse_device): Define new function.
* path.h (executable_states): Move here from fhandler.h.
(fs_info): Rename variables to *_storage and create methods for accessing same.
(path_conv): Add dev element, remove devn and unit and adjust inline methods to
accommodate.
(set_normalized_path): Declare new function.
* pinfo.cc (_pinfo::commune_recv): Add broken support for handling fifos.
(_pinfo::commune_send): Ditto.
* pipe.cc (fhandler_pipe::close): check for existence of handle before closing
it.
(handler_pipe::create): Rename from make_pipe. Change arguments to accept
fhandler_pipe array. Accommodate fifos.
(pipe): Rework to deal with fhandler_pipe::create changes.
(_pipe): Ditto.
* select.cc: Use individual device_specific types throughout rather than
indexing with obsolete device number.
(set_bits): Use is_socket call rather than checking device number.
* shared_info.h (CURR_MOUNT_MAGIC): Update.
(conv_to_win32_path): Reflect addition of device argument.
* syscalls.cc (mknod_worker): New function.
(open): Use build_fh_name to build fhandler.
(chown_worker): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(chmod_device): New function.
(chmod): Detect if this is an 'auto' device rather than an on-filesystem device
and handle appropriately. Use chmod_device to set mode of in-filesystem
devices.
(stat_worker): Eliminate path_conv argument. Call build_fh_name to construct
fhandler. Use fh->error() rather than pc->error to detect errors in fhandler
construction.
(access_worker): New function pulled from access. Accommodate in-filesystem
devices.
(access): Use access_worker.
(fpathconf): Detect if this is an 'auto' device rather than an on-filesystem
device and handle appropriately.
(mknod_worker): New function.
(mknod32): New function.
(chroot): Free normalized path -- assuming it was actually cmalloced.
* tty.cc (create_tty_master): Tweak for new device class.
(tty::common_init): Ditto.
* winsup.h (stat_worker): Remove.
(symlink_worker): Declare.
* exceptions.cc (set_process_mask): Just call sig_dispatch_pending and don't
worry about pending_signals since sig_dispatch_pending should always do the
right thing now.
(sig_handle): Reorganize SIGCONT handling to more closely conform to SUSv3.
* pinfo.h: Move __SIG enum to sigproc.h.
(PICOM_FIFO): New enum element.
(_pinfo): Remove 'thread2signal' stuff throughout class.
(_pinfo::commune_send): Make varargs.
(_pinfo::sigtodo): Eliminate.
(_pinfo::thread2signal): Ditto.
* signal.cc (kill_worker): Eliminate call to setthread2signal.
* sigproc.cc (local_sigtodo): Eliminate.
(getlocal_sigtodo): Ditto.
(sigelem): New class.
(pending_signals): New class.
(sigqueue): New variable, start of sigqueue linked list.
(sigcatch_nonmain): Eliminate.
(sigcatch_main): Eliminate.
(sigcatch_nosync): Eliminate.
(sigcomplete_nonmain): Eliminate.
(pending_signals): Eliminate.
(sig_clear): Call signal thread to clear pending signals, unless already in
signal thread.
(sigpending): Call signal thread to get pending signals.
(sig_dispatch_pending): Eliminate use of pending_signals and just check
sigqueue.
(sigproc_terminate): Eliminate all of the obsolete semaphore stuff. Close
signal pipe handle.
(sig_send): Eliminate all of the obsolete semaphore stuff and use pipe to send
signals.
(getevent): Eliminate.
(pending_signals::add): New function.
(pending_signals::del): New function.
(pending_signals::next): New function.
(wait_sig): Eliminate all of the obsolete semaphore stuff. Use pipe to
communicate and maintain a linked list of signals.
* sigproc.h: Move __SIG defines here. Add __SIGPENDING.
(sig_dispatch_pending): Remove "C" specifier.
(sig_handle): Accept a mask argument.
* thread.cc: Remove signal handling considerations throughout.
2003-09-25 08:37:18 +08:00
|
|
|
#include "fhandler.h"
|
2009-07-01 05:18:44 +08:00
|
|
|
#include "select.h"
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "dtable.h"
|
2001-04-19 05:10:15 +08:00
|
|
|
#include "cygheap.h"
|
2005-04-19 16:32:59 +08:00
|
|
|
#include "pinfo.h"
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "sigproc.h"
|
2004-10-11 10:21:31 +08:00
|
|
|
#include "cygtls.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* All these defines below should be in sys/types.h
|
|
|
|
* but because of the includes above, they may not have
|
|
|
|
* been included. We create special UNIX_xxxx versions here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NBBY
|
|
|
|
#define NBBY 8 /* number of bits in a byte */
|
|
|
|
#endif /* NBBY */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select uses bit masks of file descriptors in longs.
|
|
|
|
* These macros manipulate such bit fields (the filesystem macros use chars).
|
|
|
|
* FD_SETSIZE may be defined by the user, but the default here
|
|
|
|
* should be >= NOFILE (param.h).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define UNIX_NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
|
|
|
|
#ifndef unix_howmany
|
|
|
|
#define unix_howmany(x,y) (((x)+((y)-1))/(y))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define unix_fd_set fd_set
|
|
|
|
|
2001-03-21 03:50:28 +08:00
|
|
|
#define NULL_fd_set ((fd_set *) NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
#define sizeof_fd_set(n) \
|
2013-04-23 17:44:36 +08:00
|
|
|
((size_t) (NULL_fd_set->fds_bits + unix_howmany ((n), UNIX_NFDBITS)))
|
2000-02-18 03:38:33 +08:00
|
|
|
#define UNIX_FD_SET(n, p) \
|
|
|
|
((p)->fds_bits[(n)/UNIX_NFDBITS] |= (1L << ((n) % UNIX_NFDBITS)))
|
|
|
|
#define UNIX_FD_CLR(n, p) \
|
|
|
|
((p)->fds_bits[(n)/UNIX_NFDBITS] &= ~(1L << ((n) % UNIX_NFDBITS)))
|
|
|
|
#define UNIX_FD_ISSET(n, p) \
|
|
|
|
((p)->fds_bits[(n)/UNIX_NFDBITS] & (1L << ((n) % UNIX_NFDBITS)))
|
|
|
|
#define UNIX_FD_ZERO(p, n) \
|
2009-07-01 05:18:44 +08:00
|
|
|
memset ((caddr_t) (p), 0, sizeof_fd_set ((n)))
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2012-06-28 05:42:11 +08:00
|
|
|
#define allocfd_set(n) ({\
|
|
|
|
size_t __sfds = sizeof_fd_set (n) + 8; \
|
|
|
|
void *__res = alloca (__sfds); \
|
|
|
|
memset (__res, 0, __sfds); \
|
|
|
|
(fd_set *) __res; \
|
|
|
|
})
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
#define set_handle_or_return_if_not_open(h, s) \
|
2019-03-30 15:12:02 +08:00
|
|
|
h = (s)->fh->get_handle_cyg (); \
|
2001-04-19 05:10:15 +08:00
|
|
|
if (cygheap->fdtab.not_open ((s)->fd)) \
|
2000-02-18 03:38:33 +08:00
|
|
|
{ \
|
2005-01-13 06:40:46 +08:00
|
|
|
(s)->thread_errno = EBADF; \
|
2000-02-18 03:38:33 +08:00
|
|
|
return -1; \
|
2012-06-03 10:59:20 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
static int select (int, fd_set *, fd_set *, fd_set *, LONGLONG);
|
2012-06-28 05:42:11 +08:00
|
|
|
|
|
|
|
/* The main select code. */
|
2003-03-10 04:10:25 +08:00
|
|
|
extern "C" int
|
2016-05-19 07:14:16 +08:00
|
|
|
pselect (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|
|
|
const struct timespec *to, const sigset_t *set)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2016-05-19 07:14:16 +08:00
|
|
|
sigset_t oldset = _my_tls.sigmask;
|
2012-06-03 10:59:20 +08:00
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
__try
|
2016-03-21 04:59:47 +08:00
|
|
|
{
|
2016-05-19 07:14:16 +08:00
|
|
|
if (set)
|
|
|
|
set_signal_mask (_my_tls.sigmask, *set);
|
|
|
|
|
|
|
|
select_printf ("pselect (%d, %p, %p, %p, %p, %p)", maxfds, readfds, writefds, exceptfds, to, set);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
pthread_testcancel ();
|
|
|
|
int res;
|
|
|
|
if (maxfds < 0)
|
|
|
|
{
|
|
|
|
set_errno (EINVAL);
|
|
|
|
res = -1;
|
|
|
|
}
|
2012-07-22 06:58:20 +08:00
|
|
|
else
|
2016-05-19 07:14:16 +08:00
|
|
|
{
|
|
|
|
/* Convert to microseconds or -1 if to == NULL */
|
2018-02-07 20:07:44 +08:00
|
|
|
LONGLONG us = to ? to->tv_sec * USPERSEC
|
|
|
|
+ (to->tv_nsec + (NSPERSEC/USPERSEC) - 1)
|
|
|
|
/ (NSPERSEC/USPERSEC)
|
|
|
|
: -1LL;
|
2016-05-19 07:14:16 +08:00
|
|
|
|
|
|
|
if (to)
|
|
|
|
select_printf ("to->tv_sec %ld, to->tv_nsec %ld, us %D", to->tv_sec, to->tv_nsec, us);
|
|
|
|
else
|
|
|
|
select_printf ("to NULL, us %D", us);
|
2012-07-22 06:58:20 +08:00
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
res = select (maxfds, readfds ?: allocfd_set (maxfds),
|
|
|
|
writefds ?: allocfd_set (maxfds),
|
|
|
|
exceptfds ?: allocfd_set (maxfds), us);
|
|
|
|
}
|
|
|
|
syscall_printf ("%R = select (%d, %p, %p, %p, %p)", res, maxfds, readfds,
|
|
|
|
writefds, exceptfds, to);
|
|
|
|
|
|
|
|
if (set)
|
|
|
|
set_signal_mask (_my_tls.sigmask, oldset);
|
|
|
|
return res;
|
2012-07-22 06:58:20 +08:00
|
|
|
}
|
2016-05-19 07:14:16 +08:00
|
|
|
__except (EFAULT) {}
|
|
|
|
__endtry
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* select () is just a wrapper on pselect (). */
|
|
|
|
extern "C" int
|
|
|
|
cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|
|
|
struct timeval *to)
|
|
|
|
{
|
|
|
|
struct timespec ts;
|
|
|
|
if (to)
|
|
|
|
{
|
|
|
|
ts.tv_sec = to->tv_sec;
|
|
|
|
ts.tv_nsec = to->tv_usec * 1000;
|
|
|
|
}
|
|
|
|
return pselect (maxfds, readfds, writefds, exceptfds,
|
|
|
|
to ? &ts : NULL, NULL);
|
2012-06-28 05:42:11 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2012-06-28 05:42:11 +08:00
|
|
|
/* This function is arbitrarily split out from cygwin_select to avoid odd
|
|
|
|
gcc issues with the use of allocfd_set and improper constructor handling
|
|
|
|
for the sel variable. */
|
|
|
|
static int
|
|
|
|
select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
2016-05-19 07:14:16 +08:00
|
|
|
LONGLONG us)
|
2012-06-28 05:42:11 +08:00
|
|
|
{
|
2016-05-19 07:14:17 +08:00
|
|
|
select_stuff::wait_states wait_state = select_stuff::select_set_zero;
|
2016-01-09 21:53:06 +08:00
|
|
|
int ret = 0;
|
2001-08-27 23:59:26 +08:00
|
|
|
|
2016-01-08 00:56:33 +08:00
|
|
|
/* Record the current time for later use. */
|
2018-11-27 20:47:02 +08:00
|
|
|
LONGLONG start_time = get_clock (CLOCK_REALTIME)->usecs ();
|
2012-06-03 10:59:20 +08:00
|
|
|
|
2012-06-28 05:42:11 +08:00
|
|
|
select_stuff sel;
|
|
|
|
sel.return_on_signal = 0;
|
|
|
|
|
Cygwin: select: fix overwriting fd sets if poll returns no fd
There's a long-standing bug in select. If we have poll-only
descriptors in the fd set, select overwrites the incoming
fd sets with the polling result. If none of the fds is ready,
select has to loop again. But now the fd sets are set to all
zero and select hangs.
Fix this by utilizing the local fd sets r, w, e as storage for
the incoming fd sets and use them to initialize select_stuff.
If we have to loop, overwritung the incoming fd sets doesn't matter.
While at it, rename r, w, e to readfds_in, writefds_in, exceptfds_in.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-14 05:43:52 +08:00
|
|
|
/* Allocate fd_set structures to store incoming fd sets. */
|
|
|
|
fd_set *readfds_in = allocfd_set (maxfds);
|
|
|
|
fd_set *writefds_in = allocfd_set (maxfds);
|
|
|
|
fd_set *exceptfds_in = allocfd_set (maxfds);
|
|
|
|
memcpy (readfds_in, readfds, sizeof_fd_set (maxfds));
|
|
|
|
memcpy (writefds_in, writefds, sizeof_fd_set (maxfds));
|
|
|
|
memcpy (exceptfds_in, exceptfds, sizeof_fd_set (maxfds));
|
2012-06-28 05:42:11 +08:00
|
|
|
|
2016-01-09 21:53:06 +08:00
|
|
|
do
|
2012-06-03 10:59:20 +08:00
|
|
|
{
|
2012-06-03 11:29:47 +08:00
|
|
|
/* Build the select record per fd linked list and set state as
|
|
|
|
needed. */
|
2012-06-03 10:59:20 +08:00
|
|
|
for (int i = 0; i < maxfds; i++)
|
Cygwin: select: fix overwriting fd sets if poll returns no fd
There's a long-standing bug in select. If we have poll-only
descriptors in the fd set, select overwrites the incoming
fd sets with the polling result. If none of the fds is ready,
select has to loop again. But now the fd sets are set to all
zero and select hangs.
Fix this by utilizing the local fd sets r, w, e as storage for
the incoming fd sets and use them to initialize select_stuff.
If we have to loop, overwritung the incoming fd sets doesn't matter.
While at it, rename r, w, e to readfds_in, writefds_in, exceptfds_in.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-14 05:43:52 +08:00
|
|
|
if (!sel.test_and_set (i, readfds_in, writefds_in, exceptfds_in))
|
2012-06-03 10:59:20 +08:00
|
|
|
{
|
|
|
|
select_printf ("aborting due to test_and_set error");
|
|
|
|
return -1; /* Invalid fd, maybe? */
|
|
|
|
}
|
|
|
|
select_printf ("sel.always_ready %d", sel.always_ready);
|
|
|
|
|
2016-05-19 07:14:17 +08:00
|
|
|
if (sel.always_ready || us == 0)
|
2016-05-19 07:14:19 +08:00
|
|
|
/* Catch any active fds via sel.poll () below */
|
2016-01-26 04:00:14 +08:00
|
|
|
wait_state = select_stuff::select_ok;
|
2012-06-03 10:59:20 +08:00
|
|
|
else
|
2016-01-26 04:00:14 +08:00
|
|
|
/* wait for an fd to become active or time out */
|
Cygwin: select: fix overwriting fd sets if poll returns no fd
There's a long-standing bug in select. If we have poll-only
descriptors in the fd set, select overwrites the incoming
fd sets with the polling result. If none of the fds is ready,
select has to loop again. But now the fd sets are set to all
zero and select hangs.
Fix this by utilizing the local fd sets r, w, e as storage for
the incoming fd sets and use them to initialize select_stuff.
If we have to loop, overwritung the incoming fd sets doesn't matter.
While at it, rename r, w, e to readfds_in, writefds_in, exceptfds_in.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-14 05:43:52 +08:00
|
|
|
wait_state = sel.wait (readfds, writefds, exceptfds, us);
|
2016-01-26 04:00:14 +08:00
|
|
|
|
|
|
|
select_printf ("sel.wait returns %d", wait_state);
|
|
|
|
|
2016-05-19 07:14:17 +08:00
|
|
|
if (wait_state == select_stuff::select_ok)
|
2011-12-14 04:06:31 +08:00
|
|
|
{
|
2016-01-09 21:53:06 +08:00
|
|
|
UNIX_FD_ZERO (readfds, maxfds);
|
|
|
|
UNIX_FD_ZERO (writefds, maxfds);
|
|
|
|
UNIX_FD_ZERO (exceptfds, maxfds);
|
2016-05-19 07:14:17 +08:00
|
|
|
/* Set bit mask from sel records. This also sets ret to the
|
|
|
|
right value >= 0, matching the number of bits set in the
|
|
|
|
fds records. if ret is 0, continue to loop. */
|
|
|
|
ret = sel.poll (readfds, writefds, exceptfds);
|
2019-03-31 23:47:47 +08:00
|
|
|
if (ret < 0)
|
|
|
|
wait_state = select_stuff::select_signalled;
|
|
|
|
else if (!ret)
|
2016-05-19 07:14:17 +08:00
|
|
|
wait_state = select_stuff::select_set_zero;
|
2012-06-03 10:59:20 +08:00
|
|
|
}
|
2012-06-03 11:29:47 +08:00
|
|
|
/* Always clean up everything here. If we're looping then build it
|
|
|
|
all up again. */
|
2012-06-03 10:59:20 +08:00
|
|
|
sel.cleanup ();
|
|
|
|
sel.destroy ();
|
2016-05-19 07:14:17 +08:00
|
|
|
/* Check and recalculate timeout. */
|
|
|
|
if (us != -1LL && wait_state == select_stuff::select_set_zero)
|
2012-06-03 10:59:20 +08:00
|
|
|
{
|
2016-05-19 07:14:16 +08:00
|
|
|
select_printf ("recalculating us");
|
2018-11-27 20:47:02 +08:00
|
|
|
LONGLONG now = get_clock (CLOCK_REALTIME)->usecs ();
|
2016-06-06 22:18:53 +08:00
|
|
|
if (now >= (start_time + us))
|
2012-07-22 06:58:20 +08:00
|
|
|
{
|
|
|
|
select_printf ("timed out after verification");
|
2016-01-09 21:53:06 +08:00
|
|
|
/* Set descriptor bits to zero per POSIX. */
|
|
|
|
UNIX_FD_ZERO (readfds, maxfds);
|
|
|
|
UNIX_FD_ZERO (writefds, maxfds);
|
|
|
|
UNIX_FD_ZERO (exceptfds, maxfds);
|
2016-01-26 04:00:14 +08:00
|
|
|
wait_state = select_stuff::select_ok;
|
|
|
|
ret = 0;
|
2012-07-22 06:58:20 +08:00
|
|
|
}
|
2012-06-03 10:59:20 +08:00
|
|
|
else
|
|
|
|
{
|
2016-05-19 07:14:16 +08:00
|
|
|
us -= (now - start_time);
|
2012-06-03 10:59:20 +08:00
|
|
|
start_time = now;
|
2016-05-19 07:14:16 +08:00
|
|
|
select_printf ("us now %D", us);
|
2012-06-03 10:59:20 +08:00
|
|
|
}
|
2011-12-14 04:06:31 +08:00
|
|
|
}
|
2011-12-08 07:14:47 +08:00
|
|
|
}
|
2016-05-19 07:14:17 +08:00
|
|
|
while (wait_state == select_stuff::select_set_zero);
|
2011-12-08 07:14:47 +08:00
|
|
|
|
2016-01-26 04:00:14 +08:00
|
|
|
if (wait_state < select_stuff::select_ok)
|
2016-01-09 21:53:06 +08:00
|
|
|
ret = -1;
|
|
|
|
return ret;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-08-31 13:06:14 +08:00
|
|
|
/* Call cleanup functions for all inspected fds. Gets rid of any
|
|
|
|
executing threads. */
|
|
|
|
void
|
|
|
|
select_stuff::cleanup ()
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_record *s = &start;
|
|
|
|
|
|
|
|
select_printf ("calling cleanup routines");
|
|
|
|
while ((s = s->next))
|
|
|
|
if (s->cleanup)
|
2001-08-31 13:06:14 +08:00
|
|
|
{
|
|
|
|
s->cleanup (s, this);
|
|
|
|
s->cleanup = NULL;
|
|
|
|
}
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-08-31 13:06:14 +08:00
|
|
|
/* Destroy all storage associated with select stuff. */
|
2011-05-03 23:58:52 +08:00
|
|
|
inline void
|
|
|
|
select_stuff::destroy ()
|
2001-08-31 13:06:14 +08:00
|
|
|
{
|
2012-06-03 10:59:20 +08:00
|
|
|
select_record *s;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *snext = start.next;
|
|
|
|
|
|
|
|
select_printf ("deleting select records");
|
|
|
|
while ((s = snext))
|
|
|
|
{
|
|
|
|
snext = s->next;
|
|
|
|
delete s;
|
|
|
|
}
|
2012-06-03 10:59:20 +08:00
|
|
|
start.next = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2011-05-03 23:58:52 +08:00
|
|
|
select_stuff::~select_stuff ()
|
|
|
|
{
|
|
|
|
cleanup ();
|
|
|
|
destroy ();
|
|
|
|
}
|
|
|
|
|
2012-12-23 03:35:41 +08:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
void
|
|
|
|
select_record::dump_select_record ()
|
|
|
|
{
|
|
|
|
select_printf ("fd %d, h %p, fh %p, thread_errno %d, windows_handle %p",
|
|
|
|
fd, h, fh, thread_errno, windows_handle);
|
|
|
|
select_printf ("read_ready %d, write_ready %d, except_ready %d",
|
|
|
|
read_ready, write_ready, except_ready);
|
|
|
|
select_printf ("read_selected %d, write_selected %d, except_selected %d, except_on_write %d",
|
|
|
|
read_selected, write_selected, except_selected, except_on_write);
|
2020-03-11 20:28:27 +08:00
|
|
|
|
2012-12-23 03:35:41 +08:00
|
|
|
select_printf ("startup %p, peek %p, verify %p cleanup %p, next %p",
|
|
|
|
startup, peek, verify, cleanup, next);
|
|
|
|
}
|
|
|
|
#endif /*DEBUGGING*/
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Add a record to the select chain */
|
2009-07-01 05:18:44 +08:00
|
|
|
bool
|
2000-02-18 03:38:33 +08:00
|
|
|
select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
|
|
|
|
fd_set *exceptfds)
|
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
if (!UNIX_FD_ISSET (i, readfds) && !UNIX_FD_ISSET (i, writefds)
|
|
|
|
&& ! UNIX_FD_ISSET (i, exceptfds))
|
|
|
|
return true;
|
|
|
|
|
2012-12-20 05:15:54 +08:00
|
|
|
select_record *s = new select_record;
|
2009-07-01 05:18:44 +08:00
|
|
|
if (!s)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
s->next = start.next;
|
|
|
|
start.next = s;
|
|
|
|
|
|
|
|
if (UNIX_FD_ISSET (i, readfds) && !cygheap->fdtab.select_read (i, this))
|
|
|
|
goto err;
|
|
|
|
if (UNIX_FD_ISSET (i, writefds) && !cygheap->fdtab.select_write (i, this))
|
|
|
|
goto err;
|
|
|
|
if (UNIX_FD_ISSET (i, exceptfds) && !cygheap->fdtab.select_except (i, this))
|
|
|
|
goto err; /* error */
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (s->read_ready || s->write_ready || s->except_ready)
|
2001-11-04 10:31:58 +08:00
|
|
|
always_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2004-11-26 12:15:10 +08:00
|
|
|
if (s->windows_handle)
|
2001-11-04 10:31:58 +08:00
|
|
|
windows_used = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2012-12-23 03:35:41 +08:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
s->dump_select_record ();
|
|
|
|
#endif
|
2009-07-01 05:18:44 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
err:
|
|
|
|
start.next = s->next;
|
|
|
|
delete s;
|
|
|
|
return false;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The heart of select. Waits for an fd to do something interesting. */
|
2012-06-03 10:59:20 +08:00
|
|
|
select_stuff::wait_states
|
2000-02-18 03:38:33 +08:00
|
|
|
select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
2016-05-19 07:14:16 +08:00
|
|
|
LONGLONG us)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-04-04 02:15:01 +08:00
|
|
|
HANDLE w4[MAXIMUM_WAIT_OBJECTS];
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *s = &start;
|
2016-06-06 22:48:38 +08:00
|
|
|
DWORD m = 0, timer_idx = 0, cancel_idx = 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
/* Always wait for signals. */
|
2015-11-27 21:39:11 +08:00
|
|
|
wait_signal_arrived here (w4[m++]);
|
2016-05-19 07:14:16 +08:00
|
|
|
|
|
|
|
/* Set a timeout, or not, for WMFO. */
|
|
|
|
DWORD wmfo_timeout = us ? INFINITE : 0;
|
|
|
|
|
|
|
|
/* Optionally wait for pthread cancellation. */
|
2011-05-03 23:58:52 +08:00
|
|
|
if ((w4[m] = pthread::get_cancel_event ()) != NULL)
|
2016-06-06 22:48:38 +08:00
|
|
|
cancel_idx = m++;
|
2011-05-03 23:58:52 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Loop through the select chain, starting up anything appropriate and
|
|
|
|
counting the number of active fds. */
|
2016-06-06 22:48:38 +08:00
|
|
|
DWORD startfds = m;
|
2000-02-18 03:38:33 +08:00
|
|
|
while ((s = s->next))
|
|
|
|
{
|
2016-06-06 22:48:38 +08:00
|
|
|
/* Make sure to leave space for the timer, if we have a finite timeout. */
|
|
|
|
if (m >= MAXIMUM_WAIT_OBJECTS - (us > 0LL ? 1 : 0))
|
2000-08-11 03:33:54 +08:00
|
|
|
{
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EINVAL);
|
2012-06-03 10:59:20 +08:00
|
|
|
return select_error;
|
2000-08-11 03:33:54 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!s->startup (s, this))
|
|
|
|
{
|
2005-01-13 06:40:46 +08:00
|
|
|
s->set_select_errno ();
|
2012-06-03 10:59:20 +08:00
|
|
|
return select_error;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2012-06-03 10:59:20 +08:00
|
|
|
if (s->h != NULL)
|
2012-06-04 00:31:33 +08:00
|
|
|
{
|
|
|
|
for (DWORD i = startfds; i < m; i++)
|
|
|
|
if (w4[i] == s->h)
|
|
|
|
goto next_while;
|
|
|
|
w4[m++] = s->h;
|
|
|
|
}
|
|
|
|
next_while:;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2016-06-08 17:02:50 +08:00
|
|
|
/* Optionally create and set a waitable timer if a finite timeout has
|
2016-06-06 22:48:38 +08:00
|
|
|
been requested. Recycle cw_timer in the cygtls area so we only have
|
|
|
|
to create the timer once per thread. Since WFMO checks the handles
|
2016-06-08 17:02:50 +08:00
|
|
|
in order, we append the timer as last object, otherwise it's preferred
|
2016-06-06 22:48:38 +08:00
|
|
|
over actual events on the descriptors. */
|
|
|
|
HANDLE &wait_timer = _my_tls.locals.cw_timer;
|
|
|
|
if (us > 0LL)
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
if (!wait_timer)
|
|
|
|
{
|
|
|
|
status = NtCreateTimer (&wait_timer, TIMER_ALL_ACCESS, NULL,
|
|
|
|
NotificationTimer);
|
|
|
|
if (!NT_SUCCESS (status))
|
|
|
|
{
|
|
|
|
select_printf ("%y = NtCreateTimer ()\n", status);
|
|
|
|
return select_error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LARGE_INTEGER ms_clock_ticks = { .QuadPart = -us * 10 };
|
|
|
|
status = NtSetTimer (wait_timer, &ms_clock_ticks, NULL, NULL, FALSE,
|
|
|
|
0, NULL);
|
|
|
|
if (!NT_SUCCESS (status))
|
|
|
|
{
|
2016-06-08 17:02:50 +08:00
|
|
|
select_printf ("%y = NtSetTimer (%D)\n",
|
2016-06-06 22:48:38 +08:00
|
|
|
status, ms_clock_ticks.QuadPart);
|
|
|
|
return select_error;
|
|
|
|
}
|
|
|
|
w4[m] = wait_timer;
|
|
|
|
timer_idx = m++;
|
|
|
|
}
|
|
|
|
|
2016-05-19 07:14:16 +08:00
|
|
|
debug_printf ("m %d, us %U, wmfo_timeout %d", m, us, wmfo_timeout);
|
2012-06-03 10:59:20 +08:00
|
|
|
|
|
|
|
DWORD wait_ret;
|
|
|
|
if (!windows_used)
|
2016-05-19 07:14:16 +08:00
|
|
|
wait_ret = WaitForMultipleObjects (m, w4, FALSE, wmfo_timeout);
|
2012-06-03 10:59:20 +08:00
|
|
|
else
|
|
|
|
/* Using MWMO_INPUTAVAILABLE is the officially supported solution for
|
|
|
|
the problem that the call to PeekMessage disarms the queue state
|
|
|
|
so that a subsequent MWFMO hangs, even if there are still messages
|
|
|
|
in the queue. */
|
2016-05-19 07:14:16 +08:00
|
|
|
wait_ret = MsgWaitForMultipleObjectsEx (m, w4, wmfo_timeout,
|
2012-06-03 10:59:20 +08:00
|
|
|
QS_ALLINPUT | QS_ALLPOSTMESSAGE,
|
|
|
|
MWMO_INPUTAVAILABLE);
|
2013-12-04 04:28:55 +08:00
|
|
|
select_printf ("wait_ret %d, m = %d. verifying", wait_ret, m);
|
2012-06-03 10:59:20 +08:00
|
|
|
|
2016-06-06 22:48:38 +08:00
|
|
|
if (timer_idx)
|
2016-05-19 07:14:16 +08:00
|
|
|
{
|
|
|
|
BOOLEAN current_state;
|
2016-06-06 22:48:38 +08:00
|
|
|
NtCancelTimer (wait_timer, ¤t_state);
|
2016-05-19 07:14:16 +08:00
|
|
|
}
|
|
|
|
|
2012-06-03 10:59:20 +08:00
|
|
|
wait_states res;
|
|
|
|
switch (wait_ret)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2012-06-03 10:59:20 +08:00
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
select_printf ("signal received");
|
2012-06-03 11:29:47 +08:00
|
|
|
/* Need to get rid of everything when a signal occurs since we can't
|
|
|
|
be assured that a signal handler won't jump out of select entirely. */
|
2012-06-03 10:59:20 +08:00
|
|
|
cleanup ();
|
|
|
|
destroy ();
|
2013-01-11 23:36:40 +08:00
|
|
|
/* select() is always interrupted by a signal so set EINTR,
|
|
|
|
unconditionally, ignoring any SA_RESTART detection by
|
|
|
|
call_signal_handler(). */
|
|
|
|
_my_tls.call_signal_handler ();
|
|
|
|
set_sig_errno (EINTR);
|
|
|
|
res = select_signalled; /* Cause loop exit in cygwin_select */
|
2012-06-03 10:59:20 +08:00
|
|
|
break;
|
|
|
|
case WAIT_FAILED:
|
2012-12-20 02:44:40 +08:00
|
|
|
system_printf ("WaitForMultipleObjects failed, %E");
|
2012-06-03 10:59:20 +08:00
|
|
|
s = &start;
|
|
|
|
s->set_select_errno ();
|
|
|
|
res = select_error;
|
|
|
|
break;
|
|
|
|
case WAIT_TIMEOUT:
|
2016-06-06 22:48:38 +08:00
|
|
|
was_timeout:
|
2012-06-03 10:59:20 +08:00
|
|
|
select_printf ("timed out");
|
2012-06-10 09:57:53 +08:00
|
|
|
res = select_set_zero;
|
2012-06-03 10:59:20 +08:00
|
|
|
break;
|
2016-06-06 22:48:38 +08:00
|
|
|
case WAIT_OBJECT_0 + 1:
|
|
|
|
/* Cancel event? */
|
|
|
|
if (wait_ret == cancel_idx)
|
2012-06-03 10:59:20 +08:00
|
|
|
{
|
2011-05-02 23:28:35 +08:00
|
|
|
cleanup ();
|
2012-06-03 10:59:20 +08:00
|
|
|
destroy ();
|
|
|
|
pthread::static_cancel_self ();
|
|
|
|
/*NOTREACHED*/
|
2011-12-14 04:06:31 +08:00
|
|
|
}
|
2016-06-06 22:48:38 +08:00
|
|
|
/*FALLTHRU*/
|
2012-06-03 10:59:20 +08:00
|
|
|
default:
|
2016-06-06 22:48:38 +08:00
|
|
|
/* Timer event? */
|
|
|
|
if (wait_ret == timer_idx)
|
|
|
|
goto was_timeout;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
s = &start;
|
2016-05-19 07:14:17 +08:00
|
|
|
res = select_set_zero;
|
2016-01-08 00:56:33 +08:00
|
|
|
/* Some types of objects (e.g., consoles) wake up on "inappropriate"
|
|
|
|
events like mouse movements. The verify function will detect these
|
|
|
|
situations. If it returns false, then this wakeup was a false alarm
|
|
|
|
and we should go back to waiting. */
|
2019-03-31 23:47:47 +08:00
|
|
|
int ret = 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
while ((s = s->next))
|
2005-01-13 06:40:46 +08:00
|
|
|
if (s->saw_error ())
|
|
|
|
{
|
|
|
|
set_errno (s->saw_error ());
|
2012-06-03 10:59:20 +08:00
|
|
|
res = select_error; /* Somebody detected an error */
|
|
|
|
goto out;
|
2005-01-13 06:40:46 +08:00
|
|
|
}
|
2016-06-06 22:48:38 +08:00
|
|
|
else if ((((wait_ret >= m && s->windows_handle)
|
|
|
|
|| s->h == w4[wait_ret]))
|
2019-03-31 23:47:47 +08:00
|
|
|
&& (ret = s->verify (s, readfds, writefds, exceptfds)) > 0)
|
2016-05-19 07:14:17 +08:00
|
|
|
res = select_ok;
|
2019-03-31 23:47:47 +08:00
|
|
|
else if (ret < 0)
|
|
|
|
{
|
|
|
|
res = select_signalled;
|
|
|
|
goto out;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2016-05-19 07:14:17 +08:00
|
|
|
select_printf ("res after verify %d", res);
|
2012-06-03 10:59:20 +08:00
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
out:
|
2001-08-27 23:59:26 +08:00
|
|
|
select_printf ("returning %d", res);
|
|
|
|
return res;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
set_bits (select_record *me, fd_set *readfds, fd_set *writefds,
|
2001-10-29 13:28:24 +08:00
|
|
|
fd_set *exceptfds)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
int ready = 0;
|
2018-02-23 22:24:18 +08:00
|
|
|
fhandler_socket_wsock *sock;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("me %p, testing fd %d (%s)", me, me->fd, me->fh->get_name ());
|
|
|
|
if (me->read_selected && me->read_ready)
|
|
|
|
{
|
|
|
|
UNIX_FD_SET (me->fd, readfds);
|
|
|
|
ready++;
|
|
|
|
}
|
|
|
|
if (me->write_selected && me->write_ready)
|
|
|
|
{
|
|
|
|
UNIX_FD_SET (me->fd, writefds);
|
2018-02-23 22:24:18 +08:00
|
|
|
if (me->except_on_write && (sock = me->fh->is_wsock_socket ()))
|
2005-03-22 02:56:50 +08:00
|
|
|
{
|
2014-10-11 20:14:29 +08:00
|
|
|
/* Set readfds entry in case of a failed connect. */
|
|
|
|
if (!me->read_ready && me->read_selected
|
|
|
|
&& sock->connect_state () == connect_failed)
|
|
|
|
UNIX_FD_SET (me->fd, readfds);
|
2005-03-22 02:56:50 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
ready++;
|
|
|
|
}
|
2006-07-27 21:58:54 +08:00
|
|
|
if (me->except_selected && me->except_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2006-07-27 21:58:54 +08:00
|
|
|
UNIX_FD_SET (me->fd, exceptfds);
|
2000-02-18 03:38:33 +08:00
|
|
|
ready++;
|
|
|
|
}
|
|
|
|
select_printf ("ready %d", ready);
|
|
|
|
return ready;
|
|
|
|
}
|
|
|
|
|
2001-11-04 10:31:58 +08:00
|
|
|
/* Poll every fd in the select chain. Set appropriate fd in mask. */
|
|
|
|
int
|
|
|
|
select_stuff::poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
|
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
select_record *s = &start;
|
|
|
|
while ((s = s->next))
|
2019-03-31 23:47:47 +08:00
|
|
|
{
|
|
|
|
int ret = s->peek ? s->peek (s, true) : 1;
|
|
|
|
if (ret < 0)
|
|
|
|
return -1;
|
|
|
|
n += (ret > 0) ? set_bits (s, readfds, writefds, exceptfds) : 0;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
2000-02-21 13:20:38 +08:00
|
|
|
verify_true (select_record *, fd_set *, fd_set *, fd_set *)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
verify_ok (select_record *me, fd_set *readfds, fd_set *writefds,
|
|
|
|
fd_set *exceptfds)
|
|
|
|
{
|
|
|
|
return set_bits (me, readfds, writefds, exceptfds);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-02-21 13:20:38 +08:00
|
|
|
no_startup (select_record *, select_stuff *)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
no_verify (select_record *, fd_set *, fd_set *, fd_set *)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-01 08:57:49 +08:00
|
|
|
static int
|
|
|
|
pipe_data_available (int fd, fhandler_base *fh, HANDLE h, bool writing)
|
|
|
|
{
|
2013-04-23 17:44:36 +08:00
|
|
|
IO_STATUS_BLOCK iosb = {{0}, 0};
|
2011-06-01 08:57:49 +08:00
|
|
|
FILE_PIPE_LOCAL_INFORMATION fpli = {0};
|
2017-11-16 03:11:05 +08:00
|
|
|
NTSTATUS status;
|
2011-06-01 08:57:49 +08:00
|
|
|
|
2012-02-01 13:27:42 +08:00
|
|
|
if (fh->has_ongoing_io ())
|
2017-11-16 03:11:05 +08:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
status = NtQueryInformationFile (h, &iosb, &fpli, sizeof (fpli),
|
|
|
|
FilePipeLocalInformation);
|
|
|
|
if (!NT_SUCCESS (status))
|
2011-06-01 08:57:49 +08:00
|
|
|
{
|
2012-02-01 13:27:42 +08:00
|
|
|
/* If NtQueryInformationFile fails, optimistically assume the
|
|
|
|
pipe is writable. This could happen if we somehow
|
|
|
|
inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES
|
|
|
|
access on the write end. */
|
2017-11-16 03:11:05 +08:00
|
|
|
select_printf ("fd %d, %s, NtQueryInformationFile failed, status %y",
|
|
|
|
fd, fh->get_name (), status);
|
|
|
|
return writing ? 1 : -1;
|
|
|
|
}
|
|
|
|
if (writing)
|
|
|
|
{
|
|
|
|
/* If there is anything available in the pipe buffer then signal
|
|
|
|
that. This means that a pipe could still block since you could
|
|
|
|
be trying to write more to the pipe than is available in the
|
|
|
|
buffer but that is the hazard of select(). */
|
|
|
|
fpli.WriteQuotaAvailable = fpli.OutboundQuota - fpli.ReadDataAvailable;
|
|
|
|
if (fpli.WriteQuotaAvailable > 0)
|
|
|
|
{
|
|
|
|
paranoid_printf ("fd %d, %s, write: size %u, avail %u", fd,
|
|
|
|
fh->get_name (), fpli.OutboundQuota,
|
|
|
|
fpli.WriteQuotaAvailable);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
/* If we somehow inherit a tiny pipe (size < PIPE_BUF), then consider
|
|
|
|
the pipe writable only if it is completely empty, to minimize the
|
|
|
|
probability that a subsequent write will block. */
|
|
|
|
if (fpli.OutboundQuota < PIPE_BUF
|
|
|
|
&& fpli.WriteQuotaAvailable == fpli.OutboundQuota)
|
|
|
|
{
|
|
|
|
select_printf ("fd, %s, write tiny pipe: size %u, avail %u",
|
|
|
|
fd, fh->get_name (), fpli.OutboundQuota,
|
|
|
|
fpli.WriteQuotaAvailable);
|
|
|
|
return 1;
|
|
|
|
}
|
2012-02-01 13:27:42 +08:00
|
|
|
}
|
2017-11-16 03:11:05 +08:00
|
|
|
else if (fpli.ReadDataAvailable)
|
2012-02-01 13:27:42 +08:00
|
|
|
{
|
|
|
|
paranoid_printf ("fd %d, %s, read avail %u", fd, fh->get_name (),
|
|
|
|
fpli.ReadDataAvailable);
|
2017-11-16 03:11:05 +08:00
|
|
|
return 1;
|
2011-06-01 08:57:49 +08:00
|
|
|
}
|
2017-11-16 03:11:05 +08:00
|
|
|
if (fpli.NamedPipeState & FILE_PIPE_CLOSING_STATE)
|
|
|
|
return -1;
|
|
|
|
return 0;
|
2011-06-01 08:57:49 +08:00
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_pipe (select_record *s, bool from_select)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-04-03 06:36:44 +08:00
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, s);
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
int gotone = 0;
|
2010-04-03 06:36:44 +08:00
|
|
|
fhandler_base *fh = (fhandler_base *) s->fh;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-06-01 08:57:49 +08:00
|
|
|
DWORD dev = fh->get_device ();
|
|
|
|
if (s->read_selected && dev != FH_PIPEW)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-05-13 09:42:53 +08:00
|
|
|
if (s->read_ready)
|
|
|
|
{
|
2004-09-03 09:32:02 +08:00
|
|
|
select_printf ("%s, already ready for read", fh->get_name ());
|
2000-05-13 09:42:53 +08:00
|
|
|
gotone = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2006-06-05 04:32:58 +08:00
|
|
|
switch (fh->get_major ())
|
2000-03-12 14:29:54 +08:00
|
|
|
{
|
2011-10-20 22:02:54 +08:00
|
|
|
case DEV_PTYM_MAJOR:
|
2012-04-05 10:54:51 +08:00
|
|
|
{
|
|
|
|
fhandler_pty_master *fhm = (fhandler_pty_master *) fh;
|
|
|
|
fhm->flush_to_slave ();
|
|
|
|
}
|
2000-11-09 10:03:33 +08:00
|
|
|
break;
|
|
|
|
default:
|
2001-11-04 10:31:58 +08:00
|
|
|
if (fh->get_readahead_valid ())
|
2000-11-09 10:03:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("readahead");
|
2001-11-05 08:29:27 +08:00
|
|
|
gotone = s->read_ready = true;
|
2000-11-09 10:03:33 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2000-03-12 14:29:54 +08:00
|
|
|
}
|
2001-09-25 05:50:44 +08:00
|
|
|
|
2016-07-27 02:03:07 +08:00
|
|
|
if (fh->bg_check (SIGTTIN, true) <= bg_eof)
|
2001-09-25 05:50:44 +08:00
|
|
|
{
|
2001-11-05 08:29:27 +08:00
|
|
|
gotone = s->read_ready = true;
|
2001-09-25 05:50:44 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2011-06-01 08:57:49 +08:00
|
|
|
int n = pipe_data_available (s->fd, fh, h, false);
|
2015-03-05 20:57:34 +08:00
|
|
|
/* On PTY masters, check if input from the echo pipe is available. */
|
|
|
|
if (n == 0 && fh->get_echo_handle ())
|
|
|
|
n = pipe_data_available (s->fd, fh, fh->get_echo_handle (), false);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2011-06-01 08:57:49 +08:00
|
|
|
if (n < 0)
|
2004-09-12 11:47:57 +08:00
|
|
|
{
|
2011-06-01 08:57:49 +08:00
|
|
|
select_printf ("read: %s, n %d", fh->get_name (), n);
|
|
|
|
if (s->except_selected)
|
|
|
|
gotone += s->except_ready = true;
|
|
|
|
if (s->read_selected)
|
|
|
|
gotone += s->read_ready = true;
|
2004-09-12 11:47:57 +08:00
|
|
|
}
|
2011-06-01 08:57:49 +08:00
|
|
|
else if (n > 0)
|
2004-09-12 11:47:57 +08:00
|
|
|
{
|
2011-06-01 08:57:49 +08:00
|
|
|
select_printf ("read: %s, ready for read: avail %d", fh->get_name (), n);
|
|
|
|
gotone += s->read_ready = true;
|
|
|
|
}
|
|
|
|
if (!gotone && s->fh->hit_eof ())
|
|
|
|
{
|
|
|
|
select_printf ("read: %s, saw EOF", fh->get_name ());
|
|
|
|
if (s->except_selected)
|
|
|
|
gotone += s->except_ready = true;
|
|
|
|
if (s->read_selected)
|
|
|
|
gotone += s->read_ready = true;
|
2004-09-12 11:47:57 +08:00
|
|
|
}
|
2004-09-03 09:32:02 +08:00
|
|
|
}
|
|
|
|
|
2011-06-01 08:57:49 +08:00
|
|
|
out:
|
2019-09-05 12:22:54 +08:00
|
|
|
h = fh->get_output_handle_cyg ();
|
2011-06-01 08:57:49 +08:00
|
|
|
if (s->write_selected && dev != FH_PIPER)
|
|
|
|
{
|
|
|
|
gotone += s->write_ready = pipe_data_available (s->fd, fh, h, true);
|
|
|
|
select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
|
|
|
|
}
|
2004-09-03 09:32:02 +08:00
|
|
|
return gotone;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int start_thread_pipe (select_record *me, select_stuff *stuff);
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_pipe (void *arg)
|
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_pipe_info *pi = (select_pipe_info *) arg;
|
2006-04-23 16:39:07 +08:00
|
|
|
DWORD sleep_time = 0;
|
2010-04-03 06:36:44 +08:00
|
|
|
bool looping = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2010-04-03 06:36:44 +08:00
|
|
|
while (looping)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-04-03 06:36:44 +08:00
|
|
|
for (select_record *s = pi->start; (s = s->next); )
|
2000-02-18 03:38:33 +08:00
|
|
|
if (s->startup == start_thread_pipe)
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
if (peek_pipe (s, true))
|
2010-04-03 06:36:44 +08:00
|
|
|
looping = false;
|
2009-07-01 05:18:44 +08:00
|
|
|
if (pi->stop_thread)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("stopping");
|
2010-04-03 06:36:44 +08:00
|
|
|
looping = false;
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
2010-04-03 06:36:44 +08:00
|
|
|
if (!looping)
|
2000-02-18 03:38:33 +08:00
|
|
|
break;
|
2020-01-06 22:38:34 +08:00
|
|
|
cygwait (pi->bye, sleep_time >> 3);
|
2006-04-24 23:16:45 +08:00
|
|
|
if (sleep_time < 80)
|
2006-05-22 01:27:14 +08:00
|
|
|
++sleep_time;
|
2010-04-03 06:36:44 +08:00
|
|
|
if (pi->stop_thread)
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
start_thread_pipe (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_pipe_info *pi = stuff->device_specific_pipe;
|
|
|
|
if (pi->start)
|
|
|
|
me->h = *((select_pipe_info *) stuff->device_specific_pipe)->thread;
|
|
|
|
else
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
pi->start = &stuff->start;
|
|
|
|
pi->stop_thread = false;
|
2020-01-06 22:38:34 +08:00
|
|
|
pi->bye = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
2011-12-04 05:43:27 +08:00
|
|
|
pi->thread = new cygthread (thread_pipe, pi, "pipesel");
|
2009-07-01 05:18:44 +08:00
|
|
|
me->h = *pi->thread;
|
|
|
|
if (!me->h)
|
|
|
|
return 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-02-21 13:20:38 +08:00
|
|
|
pipe_cleanup (select_record *, select_stuff *stuff)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-04-03 06:36:44 +08:00
|
|
|
select_pipe_info *pi = (select_pipe_info *) stuff->device_specific_pipe;
|
2011-04-20 09:10:54 +08:00
|
|
|
if (!pi)
|
|
|
|
return;
|
|
|
|
if (pi->thread)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-04-03 06:36:44 +08:00
|
|
|
pi->stop_thread = true;
|
2020-01-06 22:38:34 +08:00
|
|
|
SetEvent (pi->bye);
|
2010-04-03 06:36:44 +08:00
|
|
|
pi->thread->detach ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2020-01-06 22:38:34 +08:00
|
|
|
CloseHandle (pi->bye);
|
2011-04-20 09:10:54 +08:00
|
|
|
delete pi;
|
|
|
|
stuff->device_specific_pipe = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_pipe::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
select_record *s = ss->start.next;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->startup = start_thread_pipe;
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_pipe;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->verify = verify_ok;
|
2004-09-03 09:32:02 +08:00
|
|
|
s->cleanup = pipe_cleanup;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_pipe::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
2004-09-03 09:32:02 +08:00
|
|
|
s->startup = start_thread_pipe;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_pipe;
|
2004-09-03 09:32:02 +08:00
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = pipe_cleanup;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_selected = true;
|
2004-09-03 09:32:02 +08:00
|
|
|
s->write_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_pipe::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->startup = start_thread_pipe;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_pipe;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = pipe_cleanup;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2019-03-23 03:30:41 +08:00
|
|
|
static int
|
|
|
|
peek_fifo (select_record *s, bool from_select)
|
|
|
|
{
|
|
|
|
if (cygheap->fdtab.not_open (s->fd))
|
|
|
|
{
|
|
|
|
s->thread_errno = EBADF;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int gotone = 0;
|
|
|
|
fhandler_fifo *fh = (fhandler_fifo *) s->fh;
|
|
|
|
|
|
|
|
if (s->read_selected)
|
|
|
|
{
|
|
|
|
if (s->read_ready)
|
|
|
|
{
|
|
|
|
select_printf ("%s, already ready for read", fh->get_name ());
|
|
|
|
gotone = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fh->get_readahead_valid ())
|
|
|
|
{
|
|
|
|
select_printf ("readahead");
|
|
|
|
gotone = s->read_ready = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fh->hit_eof ())
|
|
|
|
{
|
|
|
|
select_printf ("read: %s, saw EOF", fh->get_name ());
|
|
|
|
gotone = s->read_ready = true;
|
|
|
|
if (s->except_selected)
|
|
|
|
gotone += s->except_ready = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
fh->fifo_client_lock ();
|
2019-04-15 03:15:56 +08:00
|
|
|
for (int i = 0; i < fh->get_nhandlers (); i++)
|
2019-03-23 03:30:41 +08:00
|
|
|
if (fh->is_connected (i))
|
|
|
|
{
|
2019-04-15 03:16:00 +08:00
|
|
|
int n = pipe_data_available (s->fd, fh, fh->get_fc_handle (i),
|
2019-03-23 03:30:41 +08:00
|
|
|
false);
|
|
|
|
if (n > 0)
|
|
|
|
{
|
|
|
|
select_printf ("read: %s, ready for read: avail %d, client %d",
|
|
|
|
fh->get_name (), n, i);
|
|
|
|
fh->fifo_client_unlock ();
|
|
|
|
gotone += s->read_ready = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fh->fifo_client_unlock ();
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
if (s->write_selected)
|
|
|
|
{
|
|
|
|
gotone += s->write_ready
|
|
|
|
= pipe_data_available (s->fd, fh, fh->get_handle (), true);
|
|
|
|
select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
|
|
|
|
}
|
|
|
|
return gotone;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int start_thread_fifo (select_record *me, select_stuff *stuff);
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_fifo (void *arg)
|
|
|
|
{
|
|
|
|
select_fifo_info *pi = (select_fifo_info *) arg;
|
|
|
|
DWORD sleep_time = 0;
|
|
|
|
bool looping = true;
|
|
|
|
|
|
|
|
while (looping)
|
|
|
|
{
|
|
|
|
for (select_record *s = pi->start; (s = s->next); )
|
|
|
|
if (s->startup == start_thread_fifo)
|
|
|
|
{
|
|
|
|
if (peek_fifo (s, true))
|
|
|
|
looping = false;
|
|
|
|
if (pi->stop_thread)
|
|
|
|
{
|
|
|
|
select_printf ("stopping");
|
|
|
|
looping = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!looping)
|
|
|
|
break;
|
2020-01-06 22:38:34 +08:00
|
|
|
cygwait (pi->bye, sleep_time >> 3);
|
2019-03-23 03:30:41 +08:00
|
|
|
if (sleep_time < 80)
|
|
|
|
++sleep_time;
|
|
|
|
if (pi->stop_thread)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
start_thread_fifo (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
|
|
|
select_fifo_info *pi = stuff->device_specific_fifo;
|
|
|
|
if (pi->start)
|
|
|
|
me->h = *((select_fifo_info *) stuff->device_specific_fifo)->thread;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pi->start = &stuff->start;
|
|
|
|
pi->stop_thread = false;
|
2020-01-06 22:38:34 +08:00
|
|
|
pi->bye = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
2019-03-23 03:30:41 +08:00
|
|
|
pi->thread = new cygthread (thread_fifo, pi, "fifosel");
|
|
|
|
me->h = *pi->thread;
|
|
|
|
if (!me->h)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fifo_cleanup (select_record *, select_stuff *stuff)
|
|
|
|
{
|
|
|
|
select_fifo_info *pi = (select_fifo_info *) stuff->device_specific_fifo;
|
|
|
|
if (!pi)
|
|
|
|
return;
|
|
|
|
if (pi->thread)
|
|
|
|
{
|
|
|
|
pi->stop_thread = true;
|
2020-01-06 22:38:34 +08:00
|
|
|
SetEvent (pi->bye);
|
2019-03-23 03:30:41 +08:00
|
|
|
pi->thread->detach ();
|
|
|
|
}
|
2020-01-06 22:38:34 +08:00
|
|
|
CloseHandle (pi->bye);
|
2019-03-23 03:30:41 +08:00
|
|
|
delete pi;
|
|
|
|
stuff->device_specific_fifo = NULL;
|
|
|
|
}
|
|
|
|
|
2009-02-27 08:34:40 +08:00
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_fifo::select_read (select_stuff *ss)
|
2009-02-27 08:34:40 +08:00
|
|
|
{
|
2019-03-23 03:30:41 +08:00
|
|
|
if (!ss->device_specific_fifo
|
|
|
|
&& (ss->device_specific_fifo = new select_fifo_info) == NULL)
|
2009-12-23 08:35:18 +08:00
|
|
|
return NULL;
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->startup = start_thread_fifo;
|
|
|
|
s->peek = peek_fifo;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->verify = verify_ok;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->cleanup = fifo_cleanup;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_fifo::select_write (select_stuff *ss)
|
2009-02-27 08:34:40 +08:00
|
|
|
{
|
2019-03-23 03:30:41 +08:00
|
|
|
if (!ss->device_specific_fifo
|
|
|
|
&& (ss->device_specific_fifo = new select_fifo_info) == NULL)
|
2009-12-23 08:35:18 +08:00
|
|
|
return NULL;
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->startup = start_thread_fifo;
|
|
|
|
s->peek = peek_fifo;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->verify = verify_ok;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->cleanup = fifo_cleanup;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_fifo::select_except (select_stuff *ss)
|
2009-02-27 08:34:40 +08:00
|
|
|
{
|
2019-03-23 03:30:41 +08:00
|
|
|
if (!ss->device_specific_fifo
|
|
|
|
&& (ss->device_specific_fifo = new select_fifo_info) == NULL)
|
2009-12-23 08:35:18 +08:00
|
|
|
return NULL;
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->startup = start_thread_fifo;
|
|
|
|
s->peek = peek_fifo;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->verify = verify_ok;
|
2019-03-23 03:30:41 +08:00
|
|
|
s->cleanup = fifo_cleanup;
|
2009-02-27 08:34:40 +08:00
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_console (select_record *me, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
fhandler_console *fh = (fhandler_console *) me->fh;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (!me->read_selected)
|
|
|
|
return me->write_ready;
|
|
|
|
|
2016-03-16 17:25:16 +08:00
|
|
|
if (fh->get_cons_readahead_valid ())
|
2019-03-31 23:47:47 +08:00
|
|
|
return me->read_ready = true;
|
2016-03-16 17:25:16 +08:00
|
|
|
|
2019-03-31 23:47:47 +08:00
|
|
|
if (fh->input_ready)
|
|
|
|
return me->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-05-13 09:42:53 +08:00
|
|
|
if (me->read_ready)
|
|
|
|
{
|
|
|
|
select_printf ("already ready");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
INPUT_RECORD irec;
|
|
|
|
DWORD events_read;
|
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, me);
|
|
|
|
|
2019-03-31 23:47:47 +08:00
|
|
|
while (!fh->input_ready && !fh->get_cons_readahead_valid ())
|
2019-03-31 23:47:48 +08:00
|
|
|
{
|
|
|
|
if (fh->bg_check (SIGTTIN, true) <= bg_eof)
|
|
|
|
return me->read_ready = true;
|
|
|
|
else if (!PeekConsoleInputW (h, &irec, 1, &events_read) || !events_read)
|
|
|
|
break;
|
|
|
|
fh->acquire_input_mutex (INFINITE);
|
2019-08-15 13:03:00 +08:00
|
|
|
if (fhandler_console::input_winch == fh->process_input_message ()
|
|
|
|
&& global_sigs[SIGWINCH].sa_handler != SIG_IGN
|
|
|
|
&& global_sigs[SIGWINCH].sa_handler != SIG_DFL)
|
2019-03-31 23:47:48 +08:00
|
|
|
{
|
|
|
|
set_sig_errno (EINTR);
|
|
|
|
fh->release_input_mutex ();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
fh->release_input_mutex ();
|
|
|
|
}
|
2019-03-31 23:47:47 +08:00
|
|
|
if (fh->input_ready || fh->get_cons_readahead_valid ())
|
|
|
|
return me->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
return me->write_ready;
|
|
|
|
}
|
2001-11-05 14:09:15 +08:00
|
|
|
|
2001-11-04 11:29:15 +08:00
|
|
|
static int
|
|
|
|
verify_console (select_record *me, fd_set *rfds, fd_set *wfds,
|
|
|
|
fd_set *efds)
|
|
|
|
{
|
|
|
|
return peek_console (me, true);
|
|
|
|
}
|
|
|
|
|
2020-02-18 17:12:54 +08:00
|
|
|
static void console_cleanup (select_record *, select_stuff *);
|
|
|
|
|
2020-02-17 18:29:07 +08:00
|
|
|
static int
|
|
|
|
console_startup (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
2020-02-18 17:12:54 +08:00
|
|
|
fhandler_console *fh = (fhandler_console *) me->fh;
|
2020-02-17 18:29:07 +08:00
|
|
|
if (wincap.has_con_24bit_colors ())
|
|
|
|
{
|
2020-02-18 17:12:54 +08:00
|
|
|
fh->request_xterm_mode_input (true);
|
|
|
|
me->cleanup = console_cleanup;
|
2020-02-17 18:29:07 +08:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
console_cleanup (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
2020-02-18 17:12:54 +08:00
|
|
|
fhandler_console *fh = (fhandler_console *) me->fh;
|
2020-02-17 18:29:07 +08:00
|
|
|
if (wincap.has_con_24bit_colors ())
|
2020-02-18 17:12:54 +08:00
|
|
|
fh->request_xterm_mode_input (false);
|
2020-02-17 18:29:07 +08:00
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_console::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-02-17 18:29:07 +08:00
|
|
|
s->startup = console_startup;
|
2001-11-04 11:29:15 +08:00
|
|
|
s->verify = verify_console;
|
2000-08-04 09:33:33 +08:00
|
|
|
set_cursor_maybe ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_console;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
2019-03-31 23:47:47 +08:00
|
|
|
s->read_ready = input_ready || get_cons_readahead_valid ();
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_console::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
2000-08-04 09:33:33 +08:00
|
|
|
set_cursor_maybe ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_console;
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_console::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
2000-08-04 09:33:33 +08:00
|
|
|
set_cursor_maybe ();
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_console;
|
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_common::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-03-31 23:00:48 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
s->startup = start_thread_pipe;
|
|
|
|
s->peek = peek_pipe;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = pipe_cleanup;
|
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
|
|
|
return s;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_common::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-03-31 23:00:48 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
s->startup = start_thread_pipe;
|
|
|
|
s->peek = peek_pipe;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = pipe_cleanup;
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = false;
|
|
|
|
return s;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_common::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2010-03-31 23:00:48 +08:00
|
|
|
if (!ss->device_specific_pipe
|
|
|
|
&& (ss->device_specific_pipe = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
s->startup = start_thread_pipe;
|
|
|
|
s->peek = peek_pipe;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = pipe_cleanup;
|
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
|
|
|
return s;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-03-19 02:05:01 +08:00
|
|
|
static int
|
|
|
|
verify_tty_slave (select_record *me, fd_set *readfds, fd_set *writefds,
|
|
|
|
fd_set *exceptfds)
|
|
|
|
{
|
2019-09-05 12:22:54 +08:00
|
|
|
fhandler_pty_slave *ptys = (fhandler_pty_slave *) me->fh;
|
|
|
|
if (me->read_selected && !ptys->to_be_read_from_pcon () &&
|
|
|
|
IsEventSignalled (ptys->input_available_event))
|
2001-11-05 08:29:27 +08:00
|
|
|
me->read_ready = true;
|
2001-03-19 02:05:01 +08:00
|
|
|
return set_bits (me, readfds, writefds, exceptfds);
|
|
|
|
}
|
|
|
|
|
2019-08-28 02:04:02 +08:00
|
|
|
static int
|
2019-09-05 12:22:54 +08:00
|
|
|
peek_pty_slave (select_record *s, bool from_select)
|
2019-08-28 02:04:02 +08:00
|
|
|
{
|
2019-09-05 12:22:54 +08:00
|
|
|
int gotone = 0;
|
2019-08-28 02:04:02 +08:00
|
|
|
fhandler_base *fh = (fhandler_base *) s->fh;
|
2019-09-05 12:22:54 +08:00
|
|
|
fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
|
|
|
|
|
|
|
|
ptys->reset_switch_to_pcon ();
|
2020-02-09 22:46:59 +08:00
|
|
|
if (ptys->to_be_read_from_pcon ())
|
|
|
|
ptys->update_pcon_input_state (true);
|
2019-09-05 12:22:54 +08:00
|
|
|
|
|
|
|
if (s->read_selected)
|
|
|
|
{
|
|
|
|
if (s->read_ready)
|
|
|
|
{
|
|
|
|
select_printf ("%s, already ready for read", fh->get_name ());
|
|
|
|
gotone = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fh->bg_check (SIGTTIN, true) <= bg_eof)
|
|
|
|
{
|
|
|
|
gotone = s->read_ready = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsEventSignalled (ptys->input_available_event))
|
|
|
|
{
|
|
|
|
gotone = s->read_ready = true;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gotone && s->fh->hit_eof ())
|
|
|
|
{
|
|
|
|
select_printf ("read: %s, saw EOF", fh->get_name ());
|
|
|
|
if (s->except_selected)
|
|
|
|
gotone += s->except_ready = true;
|
|
|
|
if (s->read_selected)
|
|
|
|
gotone += s->read_ready = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
HANDLE h = ptys->get_output_handle_cyg ();
|
|
|
|
if (s->write_selected)
|
|
|
|
{
|
|
|
|
gotone += s->write_ready = pipe_data_available (s->fd, fh, h, true);
|
|
|
|
select_printf ("write: %s, gotone %d", fh->get_name (), gotone);
|
|
|
|
}
|
|
|
|
return gotone;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pty_slave_startup (select_record *me, select_stuff *stuff);
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_pty_slave (void *arg)
|
|
|
|
{
|
|
|
|
select_pipe_info *pi = (select_pipe_info *) arg;
|
|
|
|
DWORD sleep_time = 0;
|
|
|
|
bool looping = true;
|
|
|
|
|
|
|
|
while (looping)
|
|
|
|
{
|
|
|
|
for (select_record *s = pi->start; (s = s->next); )
|
|
|
|
if (s->startup == pty_slave_startup)
|
|
|
|
{
|
|
|
|
if (peek_pty_slave (s, true))
|
|
|
|
looping = false;
|
|
|
|
if (pi->stop_thread)
|
|
|
|
{
|
|
|
|
select_printf ("stopping");
|
|
|
|
looping = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!looping)
|
|
|
|
break;
|
2020-01-06 22:38:34 +08:00
|
|
|
cygwait (pi->bye, sleep_time >> 3);
|
2019-09-05 12:22:54 +08:00
|
|
|
if (sleep_time < 80)
|
|
|
|
++sleep_time;
|
|
|
|
if (pi->stop_thread)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
pty_slave_startup (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
|
|
|
fhandler_base *fh = (fhandler_base *) me->fh;
|
|
|
|
fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
|
2019-09-08 20:58:35 +08:00
|
|
|
if (me->read_selected)
|
2019-09-14 05:48:14 +08:00
|
|
|
ptys->mask_switch_to_pcon_in (true);
|
2019-09-05 12:22:54 +08:00
|
|
|
|
|
|
|
select_pipe_info *pi = stuff->device_specific_ptys;
|
|
|
|
if (pi->start)
|
|
|
|
me->h = *((select_pipe_info *) stuff->device_specific_ptys)->thread;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pi->start = &stuff->start;
|
|
|
|
pi->stop_thread = false;
|
2020-01-06 22:38:34 +08:00
|
|
|
pi->bye = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
2019-09-05 12:22:54 +08:00
|
|
|
pi->thread = new cygthread (thread_pty_slave, pi, "ptyssel");
|
|
|
|
me->h = *pi->thread;
|
|
|
|
if (!me->h)
|
|
|
|
return 0;
|
|
|
|
}
|
2019-08-28 02:04:02 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-09-05 12:22:54 +08:00
|
|
|
pty_slave_cleanup (select_record *me, select_stuff *stuff)
|
2019-08-28 02:04:02 +08:00
|
|
|
{
|
2019-09-05 12:22:54 +08:00
|
|
|
fhandler_base *fh = (fhandler_base *) me->fh;
|
|
|
|
fhandler_pty_slave *ptys = (fhandler_pty_slave *) fh;
|
|
|
|
if (me->read_selected)
|
2019-09-14 05:48:14 +08:00
|
|
|
ptys->mask_switch_to_pcon_in (false);
|
2019-09-05 12:22:54 +08:00
|
|
|
|
|
|
|
select_pipe_info *pi = (select_pipe_info *) stuff->device_specific_ptys;
|
|
|
|
if (!pi)
|
|
|
|
return;
|
|
|
|
if (pi->thread)
|
|
|
|
{
|
|
|
|
pi->stop_thread = true;
|
2020-01-06 22:38:34 +08:00
|
|
|
SetEvent (pi->bye);
|
2019-09-05 12:22:54 +08:00
|
|
|
pi->thread->detach ();
|
|
|
|
}
|
2020-01-06 22:38:34 +08:00
|
|
|
CloseHandle (pi->bye);
|
2019-09-05 12:22:54 +08:00
|
|
|
delete pi;
|
|
|
|
stuff->device_specific_ptys = NULL;
|
2019-08-28 02:04:02 +08:00
|
|
|
}
|
|
|
|
|
2001-03-19 02:05:01 +08:00
|
|
|
select_record *
|
2011-06-15 05:48:43 +08:00
|
|
|
fhandler_pty_slave::select_read (select_stuff *ss)
|
2001-03-19 02:05:01 +08:00
|
|
|
{
|
2019-09-05 12:22:54 +08:00
|
|
|
if (!ss->device_specific_ptys
|
|
|
|
&& (ss->device_specific_ptys = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2019-08-28 02:04:02 +08:00
|
|
|
s->startup = pty_slave_startup;
|
2019-09-05 12:22:54 +08:00
|
|
|
s->peek = peek_pty_slave;
|
2001-03-19 02:05:01 +08:00
|
|
|
s->verify = verify_tty_slave;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
2019-08-28 02:04:02 +08:00
|
|
|
s->cleanup = pty_slave_cleanup;
|
2001-03-19 02:05:01 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2019-09-05 12:22:54 +08:00
|
|
|
select_record *
|
|
|
|
fhandler_pty_slave::select_write (select_stuff *ss)
|
|
|
|
{
|
|
|
|
if (!ss->device_specific_ptys
|
|
|
|
&& (ss->device_specific_ptys = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
s->startup = pty_slave_startup;
|
|
|
|
s->peek = peek_pty_slave;
|
|
|
|
s->verify = verify_tty_slave;
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = false;
|
|
|
|
s->cleanup = pty_slave_cleanup;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_pty_slave::select_except (select_stuff *ss)
|
|
|
|
{
|
|
|
|
if (!ss->device_specific_ptys
|
|
|
|
&& (ss->device_specific_ptys = new select_pipe_info) == NULL)
|
|
|
|
return NULL;
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
s->startup = pty_slave_startup;
|
|
|
|
s->peek = peek_pty_slave;
|
|
|
|
s->verify = verify_tty_slave;
|
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
|
|
|
s->cleanup = pty_slave_cleanup;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_dev_null::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_dev_null::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_dev_null::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
2005-04-19 02:56:52 +08:00
|
|
|
s->except_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_serial (select_record *s, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-03-19 04:14:06 +08:00
|
|
|
HANDLE h;
|
2000-02-18 03:38:33 +08:00
|
|
|
COMSTAT st;
|
2020-03-19 04:14:06 +08:00
|
|
|
DWORD io_err;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2002-12-11 12:00:04 +08:00
|
|
|
fhandler_serial *fh = (fhandler_serial *) s->fh;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
set_handle_or_return_if_not_open (h, s);
|
2000-05-13 09:42:53 +08:00
|
|
|
|
2020-03-18 00:24:56 +08:00
|
|
|
if ((s->read_selected && s->read_ready)
|
|
|
|
|| (s->write_selected && s->write_ready))
|
2000-05-13 09:42:53 +08:00
|
|
|
{
|
|
|
|
select_printf ("already ready");
|
2020-03-18 00:24:56 +08:00
|
|
|
return true;
|
2000-05-13 09:42:53 +08:00
|
|
|
}
|
|
|
|
|
2020-03-19 04:14:06 +08:00
|
|
|
if (fh->get_readahead_valid ())
|
|
|
|
return s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-03-19 04:14:06 +08:00
|
|
|
if (!ClearCommError (h, &io_err, &st))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-03-23 20:08:32 +08:00
|
|
|
select_printf ("ClearCommError %E");
|
2000-02-18 03:38:33 +08:00
|
|
|
goto err;
|
|
|
|
}
|
2020-03-19 04:14:06 +08:00
|
|
|
if (st.cbInQue)
|
|
|
|
return s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-03-18 00:24:56 +08:00
|
|
|
return 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
err:
|
|
|
|
if (GetLastError () == ERROR_OPERATION_ABORTED)
|
|
|
|
{
|
|
|
|
select_printf ("operation aborted");
|
2020-03-19 04:14:06 +08:00
|
|
|
return false;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2005-01-13 06:40:46 +08:00
|
|
|
s->set_select_errno ();
|
2000-02-18 03:38:33 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-03-19 04:14:06 +08:00
|
|
|
static void
|
|
|
|
serial_read_cleanup (select_record *s, select_stuff *stuff)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-03-19 04:14:06 +08:00
|
|
|
if (s->h)
|
|
|
|
{
|
2020-03-24 04:06:00 +08:00
|
|
|
HANDLE h = ((fhandler_serial *) s->fh)->get_handle_cyg ();
|
2020-03-19 04:14:06 +08:00
|
|
|
DWORD undefined;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2020-03-19 04:14:06 +08:00
|
|
|
if (h)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-03-19 04:14:06 +08:00
|
|
|
CancelIo (h);
|
2020-03-24 04:06:00 +08:00
|
|
|
GetOverlappedResult (h, &s->fh_data_serial->ov, &undefined, TRUE);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2020-03-24 04:06:00 +08:00
|
|
|
CloseHandle (s->fh_data_serial->ov.hEvent);
|
|
|
|
delete s->fh_data_serial;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-23 20:08:32 +08:00
|
|
|
static int
|
2020-03-20 17:37:17 +08:00
|
|
|
verify_serial (select_record *me, fd_set *rfds, fd_set *wfds, fd_set *efds)
|
|
|
|
{
|
|
|
|
return peek_serial (me, true);
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_serial::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2020-03-24 00:23:19 +08:00
|
|
|
COMSTAT st;
|
|
|
|
DWORD io_err;
|
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2020-03-19 04:14:06 +08:00
|
|
|
|
|
|
|
s->startup = no_startup;
|
2020-03-20 17:37:17 +08:00
|
|
|
s->verify = verify_serial;
|
2020-03-19 04:14:06 +08:00
|
|
|
s->cleanup = serial_read_cleanup;
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_serial;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
2020-03-24 04:06:00 +08:00
|
|
|
|
|
|
|
s->fh_data_serial = new (fh_select_data_serial);
|
|
|
|
s->fh_data_serial->ov.hEvent = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
|
|
|
|
|
2020-03-19 04:14:06 +08:00
|
|
|
/* This is apparently necessary for the com0com driver.
|
|
|
|
See: http://cygwin.com/ml/cygwin/2009-01/msg00667.html */
|
|
|
|
SetCommMask (get_handle_cyg (), 0);
|
|
|
|
SetCommMask (get_handle_cyg (), EV_RXCHAR);
|
2020-03-24 00:23:19 +08:00
|
|
|
if (ClearCommError (get_handle_cyg (), &io_err, &st) && st.cbInQue)
|
2020-03-24 04:06:00 +08:00
|
|
|
s->read_ready = true;
|
|
|
|
else if (WaitCommEvent (get_handle_cyg (), &s->fh_data_serial->event,
|
|
|
|
&s->fh_data_serial->ov))
|
|
|
|
s->read_ready = true;
|
|
|
|
else if (GetLastError () == ERROR_IO_PENDING)
|
|
|
|
s->h = s->fh_data_serial->ov.hEvent;
|
|
|
|
else
|
|
|
|
select_printf ("WaitCommEvent %E");
|
|
|
|
|
|
|
|
/* No overlapped operation? Destroy the helper struct */
|
|
|
|
if (!s->h)
|
2020-03-23 20:08:32 +08:00
|
|
|
{
|
2020-03-24 04:06:00 +08:00
|
|
|
CloseHandle (s->fh_data_serial->ov.hEvent);
|
|
|
|
delete s->fh_data_serial;
|
2020-03-24 00:23:19 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_serial::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2020-03-19 04:14:06 +08:00
|
|
|
|
|
|
|
s->startup = no_startup;
|
2020-03-20 17:37:17 +08:00
|
|
|
s->verify = verify_serial;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_serial;
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_serial::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
2020-03-19 04:14:06 +08:00
|
|
|
|
|
|
|
s->startup = no_startup;
|
2020-03-20 17:37:17 +08:00
|
|
|
s->verify = verify_serial;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_serial;
|
|
|
|
s->except_selected = false; // Can't do this
|
|
|
|
s->except_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_base::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2019-03-30 15:12:02 +08:00
|
|
|
s->h = get_handle_cyg ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_base::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2019-03-30 15:12:02 +08:00
|
|
|
s->h = get_output_handle_cyg ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_base::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
s->h = NULL;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_socket (select_record *me, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2018-02-23 22:24:18 +08:00
|
|
|
fhandler_socket_wsock *fh = (fhandler_socket_wsock *) me->fh;
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
long events;
|
2006-07-27 21:58:54 +08:00
|
|
|
/* Don't play with the settings again, unless having taken a deep look into
|
|
|
|
Richard W. Stevens Network Programming book. Thank you. */
|
|
|
|
long evt_mask = (me->read_selected ? (FD_READ | FD_ACCEPT | FD_CLOSE) : 0)
|
|
|
|
| (me->write_selected ? (FD_WRITE | FD_CONNECT | FD_CLOSE) : 0)
|
|
|
|
| (me->except_selected ? FD_OOB : 0);
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
int ret = fh->evaluate_events (evt_mask, events, false);
|
|
|
|
if (me->read_selected)
|
2006-07-27 21:58:54 +08:00
|
|
|
me->read_ready |= ret || !!(events & (FD_READ | FD_ACCEPT | FD_CLOSE));
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
if (me->write_selected)
|
2006-07-27 21:58:54 +08:00
|
|
|
me->write_ready |= ret || !!(events & (FD_WRITE | FD_CONNECT | FD_CLOSE));
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
if (me->except_selected)
|
2006-07-27 21:58:54 +08:00
|
|
|
me->except_ready |= !!(events & FD_OOB);
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
|
2006-07-27 21:58:54 +08:00
|
|
|
select_printf ("read_ready: %d, write_ready: %d, except_ready: %d",
|
|
|
|
me->read_ready, me->write_ready, me->except_ready);
|
2001-10-26 12:06:27 +08:00
|
|
|
return me->read_ready || me->write_ready || me->except_ready;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int start_thread_socket (select_record *, select_stuff *);
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_socket (void *arg)
|
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_socket_info *si = (select_socket_info *) arg;
|
2009-07-06 23:42:01 +08:00
|
|
|
DWORD timeout = (si->num_w4 <= MAXIMUM_WAIT_OBJECTS)
|
|
|
|
? INFINITE
|
|
|
|
: (64 / (roundup2 (si->num_w4, MAXIMUM_WAIT_OBJECTS)
|
|
|
|
/ MAXIMUM_WAIT_OBJECTS));
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
bool event = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2012-06-10 09:57:53 +08:00
|
|
|
select_printf ("stuff_start %p, timeout %u", si->start, timeout);
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
while (!event)
|
|
|
|
{
|
|
|
|
for (select_record *s = si->start; (s = s->next); )
|
|
|
|
if (s->startup == start_thread_socket)
|
|
|
|
if (peek_socket (s, false))
|
|
|
|
event = true;
|
|
|
|
if (!event)
|
2009-07-06 23:42:01 +08:00
|
|
|
for (int i = 0; i < si->num_w4; i += MAXIMUM_WAIT_OBJECTS)
|
2012-03-08 17:36:11 +08:00
|
|
|
switch (WaitForMultipleObjects (MIN (si->num_w4 - i,
|
2006-10-12 00:21:12 +08:00
|
|
|
MAXIMUM_WAIT_OBJECTS),
|
|
|
|
si->w4 + i, FALSE, timeout))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
case WAIT_FAILED:
|
|
|
|
goto out;
|
2009-07-06 23:42:01 +08:00
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
continue;
|
2006-10-12 00:21:12 +08:00
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
if (!i) /* Socket event set. */
|
2007-02-20 08:16:18 +08:00
|
|
|
goto out;
|
2009-07-06 23:42:01 +08:00
|
|
|
/*FALLTHRU*/
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
default:
|
|
|
|
break;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
}
|
|
|
|
out:
|
|
|
|
select_printf ("leaving thread_socket");
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-06 23:42:01 +08:00
|
|
|
static inline bool init_tls_select_info () __attribute__ ((always_inline));
|
|
|
|
static inline bool
|
|
|
|
init_tls_select_info ()
|
|
|
|
{
|
|
|
|
if (!_my_tls.locals.select.sockevt)
|
|
|
|
{
|
|
|
|
_my_tls.locals.select.sockevt = CreateEvent (&sec_none_nih, TRUE, FALSE,
|
|
|
|
NULL);
|
|
|
|
if (!_my_tls.locals.select.sockevt)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (!_my_tls.locals.select.ser_num)
|
|
|
|
{
|
|
|
|
_my_tls.locals.select.ser_num
|
|
|
|
= (LONG *) malloc (MAXIMUM_WAIT_OBJECTS * sizeof (LONG));
|
|
|
|
if (!_my_tls.locals.select.ser_num)
|
|
|
|
return false;
|
|
|
|
_my_tls.locals.select.w4
|
|
|
|
= (HANDLE *) malloc (MAXIMUM_WAIT_OBJECTS * sizeof (HANDLE));
|
|
|
|
if (!_my_tls.locals.select.w4)
|
|
|
|
{
|
|
|
|
free (_my_tls.locals.select.ser_num);
|
|
|
|
_my_tls.locals.select.ser_num = NULL;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_my_tls.locals.select.max_w4 = MAXIMUM_WAIT_OBJECTS;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
|
|
|
start_thread_socket (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_socket_info *si;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
if ((si = (select_socket_info *) stuff->device_specific_socket))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2002-08-02 00:20:31 +08:00
|
|
|
me->h = *si->thread;
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2009-07-01 05:18:44 +08:00
|
|
|
si = new select_socket_info;
|
2009-07-06 23:42:01 +08:00
|
|
|
|
|
|
|
if (!init_tls_select_info ())
|
2014-06-23 22:56:45 +08:00
|
|
|
{
|
|
|
|
delete si;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-06 23:42:01 +08:00
|
|
|
|
|
|
|
si->ser_num = _my_tls.locals.select.ser_num;
|
|
|
|
si->w4 = _my_tls.locals.select.w4;
|
|
|
|
|
|
|
|
si->w4[0] = _my_tls.locals.select.sockevt;
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
si->num_w4 = 1;
|
2009-07-06 23:42:01 +08:00
|
|
|
|
|
|
|
select_record *s = &stuff->start;
|
2000-02-18 03:38:33 +08:00
|
|
|
while ((s = s->next))
|
|
|
|
if (s->startup == start_thread_socket)
|
|
|
|
{
|
2006-07-28 16:50:46 +08:00
|
|
|
/* No event/socket should show up multiple times. Every socket
|
|
|
|
is uniquely identified by its serial number in the global
|
|
|
|
wsock_events record. */
|
2018-02-23 22:24:18 +08:00
|
|
|
const LONG ser_num = ((fhandler_socket_wsock *) s->fh)->serial_number ();
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
for (int i = 1; i < si->num_w4; ++i)
|
2006-07-28 16:50:46 +08:00
|
|
|
if (si->ser_num[i] == ser_num)
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
goto continue_outer_loop;
|
2009-07-06 23:42:01 +08:00
|
|
|
if (si->num_w4 >= _my_tls.locals.select.max_w4)
|
2006-07-28 16:50:46 +08:00
|
|
|
{
|
2006-10-12 00:21:12 +08:00
|
|
|
LONG *nser = (LONG *) realloc (si->ser_num,
|
2009-07-06 23:42:01 +08:00
|
|
|
(_my_tls.locals.select.max_w4
|
|
|
|
+ MAXIMUM_WAIT_OBJECTS)
|
2006-10-12 00:21:12 +08:00
|
|
|
* sizeof (LONG));
|
|
|
|
if (!nser)
|
2014-06-23 22:56:45 +08:00
|
|
|
{
|
|
|
|
delete si;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-06 23:42:01 +08:00
|
|
|
_my_tls.locals.select.ser_num = si->ser_num = nser;
|
2006-10-12 00:21:12 +08:00
|
|
|
HANDLE *nw4 = (HANDLE *) realloc (si->w4,
|
2009-07-06 23:42:01 +08:00
|
|
|
(_my_tls.locals.select.max_w4
|
|
|
|
+ MAXIMUM_WAIT_OBJECTS)
|
2006-10-12 00:21:12 +08:00
|
|
|
* sizeof (HANDLE));
|
|
|
|
if (!nw4)
|
2014-06-23 22:56:45 +08:00
|
|
|
{
|
|
|
|
delete si;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-06 23:42:01 +08:00
|
|
|
_my_tls.locals.select.w4 = si->w4 = nw4;
|
|
|
|
_my_tls.locals.select.max_w4 += MAXIMUM_WAIT_OBJECTS;
|
2006-07-28 16:50:46 +08:00
|
|
|
}
|
2006-10-12 00:21:12 +08:00
|
|
|
si->ser_num[si->num_w4] = ser_num;
|
2018-02-23 22:24:18 +08:00
|
|
|
si->w4[si->num_w4++] = ((fhandler_socket_wsock *) s->fh)->wsock_event ();
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
continue_outer_loop:
|
|
|
|
;
|
|
|
|
}
|
2009-07-01 05:18:44 +08:00
|
|
|
stuff->device_specific_socket = si;
|
2000-02-18 03:38:33 +08:00
|
|
|
si->start = &stuff->start;
|
|
|
|
select_printf ("stuff_start %p", &stuff->start);
|
2011-12-04 05:43:27 +08:00
|
|
|
si->thread = new cygthread (thread_socket, si, "socksel");
|
2002-08-02 00:20:31 +08:00
|
|
|
me->h = *si->thread;
|
|
|
|
return 1;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-02-21 13:20:38 +08:00
|
|
|
socket_cleanup (select_record *, select_stuff *stuff)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_socket_info *si = (select_socket_info *) stuff->device_specific_socket;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("si %p si->thread %p", si, si ? si->thread : NULL);
|
2011-04-20 23:32:31 +08:00
|
|
|
if (!si)
|
|
|
|
return;
|
|
|
|
if (si->thread)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
SetEvent (si->w4[0]);
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Wait for thread to go away */
|
2002-08-02 00:20:31 +08:00
|
|
|
si->thread->detach ();
|
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/version.h: Bump DLL version to 1.7.0.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* select.h: Remove.
* fhandler_socket.cc: Don't include select.h.
* select.cc: Ditto.
2006-07-25 Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Drop socket related includes.
(struct _local_storage): Remove exitsock and exitsock_sin. Add
select_sockevt.
* cygtls.cc: Accomodate above change throughout.
* fhandler.h (class fhandler_socket): Make wsock_evt public.
* fhandler_socket.cc (fhandler_socket::fhandler_socket): Accomodate
reordering members.
(fhandler_socket::evaluate_events): Drop FD_CONNECT event as soon as
it gets read once. Never remove FD_WRITE event here.
(fhandler_socket::wait_for_events): Wait 50 ms instead of INFINITE for
socket events.
(fhandler_socket::accept): Fix conditional. Set wsock_events members
of accepted socket to useful start values.
(fhandler_socket::recv_internal): Always drop FD_READ/FD_OOB events from
wsock_events after the call to WSARecvFrom.
(fhandler_socket::send_internal): Drop FD_WRITE event from wsock_events
if the call to WSASendTo fails with WSAEWOULDBLOCK. Fix return value
condition.
* select.cc (struct socketinf): Change to accomodate using socket event
handling.
(peek_socket): Use event handling for peeking socket.
(thread_socket): Ditto.
(start_thread_socket): Ditto.
(socket_cleanup): Same here.
* tlsoffsets.h: Regenerate.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Rearrange slightly to keep
event handling methods and members together. Drop owner status flag.
Split wait method. Rename event handling methods for readability.
* fhandler_socket.cc (struct wsa_event): Add owner field.
(LOCK_EVENTS): New macro.
(UNLOCK_EVENTS): Ditto.
(fhandler_socket::init_events): rename from prepare.
(fhandler_socket::evaluate_events): First half of former wait method.
Do everything but wait. Allow specifiying whether or not events from
event_mask should be erased from wsock_events->events. Simplify
OOB handling. Allow sending SIGURG to any process (group).
(fhandler_socket::wait_for_events): Second half of former wait method.
Call evaluate_events and wait in a loop if socket is blocking.
(fhandler_socket::release_events): Rename from release.
(fhandler_socket::connect): Accomodate above name changes.
(fhandler_socket::accept): Ditto.
(fhandler_socket::recv_internal): Ditto.
(fhandler_socket::send_internal): Ditto.
(fhandler_socket::close): Ditto.
(fhandler_socket::fcntl): Always set owner to given input value on
F_SETOWN. Handle F_GETOWN.
* net.cc (fdsock): Accomodate above name changes.
2006-07-20 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Set Winsock errno to
WSAEWOULDBLOCK instead of WSAEINPROGRESS.
2006-07-18 Brian Ford <Brian.Ford@FlightSafety.com>
Corinna Vinschen <corinna@vinschen.de>
* winsup.h (mmap_region_status): New enum.
(mmap_is_attached_or_noreserve_page): Adjust prototype and rename
as below.
* mmap.cc (mmap_is_attached_or_noreserve_page): Rename
mmap_is_attached_or_noreserve. Add region length parameter.
Return enum above.
* exceptions.cc (_cygtls::handle_exceptions): Accomodate above.
* fhandler.cc (fhandler_base::raw_read): Call above for NOACCESS
errors and retry on success to allow reads into untouched
MAP_NORESERVE buffers.
2006-07-18 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din (posix_openpt): Export.
* tty.cc (posix_openpt): New function.
* include/cygwin/stdlib.h (posix_openpt): Declare.
* include/cygwin/version.h: Bump API minor number.
2006-07-14 Corinna Vinschen <corinna@vinschen.de>
* security.cc (get_token_group_sidlist): Always add the interactive
group to the token. Add comment. Create logon_id group SID by
copying it from incoming group list.
(create_token): Add subauth_token parameter. Use information in
subauth_token if present. Tweak SourceIdentifier if subauth_token
is present for debugging purposes.
* security.h (create_token): Add subauth_token parameter in declaration.
* syscalls.cc (seteuid32): Call subauth first. Call create_token
regardless. Use subauth token in call to create_token if subauth
succeeded.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* include/netinet/in.h: Update copyright.
2006-07-13 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::wait): Rework function so that
WaitForMultipleObjects is really only called when necessary.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* include/netdb.h: Declare rcmd, rcmd_af, rexec, rresvport,
rresvport_af, iruserok, iruserok_sa, ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (DLL_OFILES): Drop iruserok.o. Add rcmd.o.
* autoload.cc (rcmd): Drop definition.
* cygwin.din: Export bindresvport, bindresvport_sa, iruserok_sa,
rcmd_af, rresvport_af.
* net.cc (cygwin_rcmd): Remove.
(last_used_bindresvport): Rename from last_used_rrecvport.
(cygwin_bindresvport_sa): New function implementing bindresvport_sa.
(cygwin_bindresvport): New function implementing bindresvport.
(cygwin_rresvport): Remove.
* include/cygwin/version.h: Bump API minor number.
* include/netinet/in.h: Declare bindresvport and bindresvport_sa.
* libc/iruserok.c: Remove file.
* libc/rcmd.cc: New file implementing rcmd, rcmd_af, rresvport,
rresvport_af, iruserok_sa, iruserok and ruserok.
2006-07-12 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::getsockname): Return valid
result for unbound sockets.
2006-07-11 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::fixup_after_fork): Handle
wsock_mtx and wsock_evt on fork, thus handling close_on_exec correctly.
(fhandler_socket::fixup_after_exec): Drop misguided attempt to handle
close_on_exec here.
(fhandler_socket::dup): Call fixup_after_fork with NULL parent.
Add comment.
(fhandler_socket::set_close_on_exec): Handle wsock_mtx and wsock_evt.
2006-07-10 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_socket): Add wsock_mtx, wsock_evt
and wsock_events members. Remove closed status flag, add listener
status flag. Accomodate new implementation of socket event handling
methods. Declare recv* and send* functions ssize_t as the POSIX
equivalents.
(fhandler_socket::recv_internal): Declare.
(fhandler_socket::send_internal): Ditto.
* fhandler_socket.cc (EVENT_MASK): Define mask of selected events.
(fhandler_socket::fhandler_socket): Initialize new members.
(fhandler_socket::af_local_setblocking): Don't actually set the
socket to blocking mode. Keep sane event selection.
(fhandler_socket::af_local_unsetblocking): Don't actually set the
socket to previous blocking setting, just remember it.
(struct wsa_event): New structure to keep event data per shared
socket.
(NUM_SOCKS): Define number of shared sockets concurrently handled by
all active Cygwin processes.
(wsa_events): New shared datastructure keeping all wsa_event records.
(socket_serial_number): New shared variable to identify shared sockets.
(wsa_slot_mtx): Global mutex to serialize wsa_events access.
(search_wsa_event_slot): New static function to select a new wsa_event
slot for a new socket.
(fhandler_socket::prepare): Rewrite. Prepare event selection
per new socket.
(fhandler_socket::wait): Rewrite. Wait for socket events in thread
safe and multiple process safe.
(fhandler_socket::release): Rewrite. Close per-socket descriptor
mutex handle and event handle.
(fhandler_socket::dup): Duplicate wsock_mtx and wsock_evt. Fix
copy-paste error in debug output.
(fhandler_socket::connect): Accomodate new event handling.
(fhandler_socket::listen): Set listener flag on successful listen.
(fhandler_socket::accept): Accomodate new event handling.
(fhandler_socket::recv_internal): New inline method centralizing
common recv code.
(fhandler_socket::recvfrom): Call recv_internal now.
(fhandler_socket::recvmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::send_internal): New inline method centralizing
common send code.
(fhandler_socket::sendto): Call send_internal now.
(fhandler_socket::sendmsg): Ditto. Streamline copying from iovec
to WSABUF.
(fhandler_socket::close): Call release now.
(fhandler_socket::ioctl): Never actually switch to blocking mode.
Just keep track of the setting.
* net.cc (fdsock): Call prepare now.
(cygwin_connect): Revert again to event driven technique.
(cygwin_accept): Ditto.
* poll.cc (poll): Don't call recvfrom on a listening socket.
Remove special case for failing recvfrom.
* include/sys/socket.h: Declare recv* and send* functions ssize_t as
requested by POSIX.
2006-07-07 Corinna Vinschen <corinna@vinschen.de>
* net.cc (cygwin_inet_ntop): Fix data type of forth parameter.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* include/cygwin/in6.h (struct in6_addr): Fix typo.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* cygwin.din: Export in6addr_any, in6addr_loopback, freeaddrinfo,
gai_strerror, getaddrinfo, getnameinfo.
* fhandler_socket.cc: Include cygwin/in6.h.
(get_inet_addr): Accomodate AF_INET6 usage.
(fhandler_socket::connect): Ditto.
(fhandler_socket::listen): Ditto.
(fhandler_socket::sendto): Ditto.
* net.cc: Include cygwin/in6.h.
(in6addr_any): Define.
(in6addr_loopback): Define.
(cygwin_socket): Accomodate AF_INET6 usage.
(socketpair): Bind socketpairs only to loopback for security.
(inet_pton4): New static function.
(inet_pton6): Ditto.
(cygwin_inet_pton): New AF_INET6 aware inet_pton implementation.
(inet_ntop4): New static function.
(inet_ntop6): Ditto.
(cygwin_inet_ntop): New AF_INET6 aware inet_ntop implementation.
(ga_aistruct): New static function.
(ga_clone): Ditto.
(ga_echeck): Ditto.
(ga_nsearch): Ditto.
(ga_port): Ditto.
(ga_serv): Ditto.
(ga_unix): Ditto.
(gn_ipv46): Ditto.
(ipv4_freeaddrinfo): Ditto.
(ipv4_getaddrinfo): Ditto.
(ipv4_getnameinfo): Ditto.
(gai_errmap_t): New structure holding error code - error string mapping.
(cygwin_gai_strerror): New function implementing gai_strerror.
(w32_to_gai_err): New static function.
(get_ipv6_funcs): Ditto.
(load_ipv6_funcs): Ditto.
(cygwin_freeaddrinfo): New function implementing freeaddrinfo.
(cygwin_getaddrinfo): New function implementing getaddrinfo.
(cygwin_getnameinfo): New function implementing getnameinfo.
* include/netdb.h: Include stdint.h and cygwin/socket.h. Define
data types and macros used by getaddrinfo and friends. Declare
freeaddrinfo, gai_strerror, getaddrinfo and getnameinfo.
* include/cygwin/in.h: Add IPv6 related IPPROTOs. Remove definition
of struct sockaddr_in6. Include cygwin/in6.h instead.
* include/cygwin/in6.h: New header file defining IPv6 releated
data types and macros.
* include/cygwin/socket.h: Enable AF_INET6 and PF_INET6. Add
IPv6 related socket options.
* include/cygwin/version.h: Bump API minor number.
2006-07-06 Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (DsGetDcNameA): Define.
(NetGetAnyDCName): Define.
* security.cc: Include dsgetdc.h.
(DsGetDcNameA): Declare.
(DS_FORCE_REDISCOVERY): Define.
(get_logon_server): Add bool parameter to control rediscovery of DC.
Use DsGetDcNameA function if supported, NetGetDCName/NetGetAnyDCName
otherwise.
(get_server_groups): Rediscover DC if get_user_groups fails and
try again.
(get_reg_security): Use correct error code macro when testing
RegGetKeySecurity return value.
* security.h (get_logon_server): Remove default vaue from wserver
parameter. Add rediscovery parameter.
* uinfo.cc (cygheap_user::env_logsrv): Accomodate rediscovery parameter
in call to get_logon_server.
2006-07-26 03:23:23 +08:00
|
|
|
ResetEvent (si->w4[0]);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2011-04-20 23:32:31 +08:00
|
|
|
delete si;
|
|
|
|
stuff->device_specific_socket = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("returning");
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2018-02-23 22:24:18 +08:00
|
|
|
fhandler_socket_wsock::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = start_thread_socket;
|
|
|
|
s->verify = verify_true;
|
|
|
|
s->cleanup = socket_cleanup;
|
|
|
|
}
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_socket;
|
2001-08-31 13:06:14 +08:00
|
|
|
s->read_ready = saw_shutdown_read ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2018-02-23 22:24:18 +08:00
|
|
|
fhandler_socket_wsock::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = start_thread_socket;
|
|
|
|
s->verify = verify_true;
|
|
|
|
s->cleanup = socket_cleanup;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_socket;
|
2004-04-10 21:45:10 +08:00
|
|
|
s->write_ready = saw_shutdown_write () || connect_state () == unconnected;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_selected = true;
|
2005-04-19 02:56:52 +08:00
|
|
|
if (connect_state () != unconnected)
|
2002-07-06 19:16:07 +08:00
|
|
|
{
|
|
|
|
s->except_ready = saw_shutdown_write () || saw_shutdown_read ();
|
|
|
|
s->except_on_write = true;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2018-02-23 22:24:18 +08:00
|
|
|
fhandler_socket_wsock::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = start_thread_socket;
|
|
|
|
s->verify = verify_true;
|
|
|
|
s->cleanup = socket_cleanup;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_socket;
|
2001-08-31 13:06:14 +08:00
|
|
|
/* FIXME: Is this right? Should these be used as criteria for except? */
|
|
|
|
s->except_ready = saw_shutdown_write () || saw_shutdown_read ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2018-06-26 22:31:17 +08:00
|
|
|
#ifdef __WITH_AF_UNIX
|
|
|
|
|
2018-02-24 03:59:21 +08:00
|
|
|
select_record *
|
|
|
|
fhandler_socket_unix::select_read (select_stuff *ss)
|
|
|
|
{
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2019-03-30 15:12:02 +08:00
|
|
|
s->h = get_handle_cyg ();
|
2018-02-24 03:59:21 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = true;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_socket_unix::select_write (select_stuff *ss)
|
|
|
|
{
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
s->h = get_handle ();
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_socket_unix::select_except (select_stuff *ss)
|
|
|
|
{
|
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
s->h = NULL;
|
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2018-06-26 22:31:17 +08:00
|
|
|
#endif /* __WITH_AF_UNIX */
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_windows (select_record *me, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
MSG m;
|
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, me);
|
2013-10-30 17:44:47 +08:00
|
|
|
/* We need the hWnd value, not the io_handle. */
|
|
|
|
h = ((fhandler_windows *) me->fh)->get_hwnd ();
|
2000-05-13 09:42:53 +08:00
|
|
|
|
|
|
|
if (me->read_selected && me->read_ready)
|
|
|
|
return 1;
|
|
|
|
|
2011-05-01 22:35:12 +08:00
|
|
|
if (PeekMessageW (&m, (HWND) h, 0, 0, PM_NOREMOVE))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
me->read_ready = true;
|
2011-12-11 09:25:20 +08:00
|
|
|
select_printf ("window %d(%p) ready", me->fd, h);
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2011-12-11 09:25:20 +08:00
|
|
|
select_printf ("window %d(%p) not ready", me->fd, h);
|
2000-02-18 03:38:33 +08:00
|
|
|
return me->write_ready;
|
|
|
|
}
|
|
|
|
|
2001-11-04 11:29:15 +08:00
|
|
|
static int
|
|
|
|
verify_windows (select_record *me, fd_set *rfds, fd_set *wfds,
|
|
|
|
fd_set *efds)
|
|
|
|
{
|
|
|
|
return peek_windows (me, true);
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_windows::select_read (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
}
|
2001-11-04 11:29:15 +08:00
|
|
|
s->verify = verify_windows;
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_windows;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_selected = true;
|
|
|
|
s->read_ready = false;
|
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_windows::select_write (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_windows;
|
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2009-07-01 05:18:44 +08:00
|
|
|
fhandler_windows::select_except (select_stuff *ss)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2009-07-01 05:18:44 +08:00
|
|
|
select_record *s = ss->start.next;
|
|
|
|
if (!s->startup)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_windows;
|
|
|
|
s->except_selected = true;
|
2005-04-19 02:56:52 +08:00
|
|
|
s->except_ready = false;
|
2001-11-04 10:31:58 +08:00
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
2019-01-14 06:13:33 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
peek_signalfd (select_record *me, bool)
|
|
|
|
{
|
|
|
|
if (((fhandler_signalfd *) me->fh)->poll () == 0)
|
|
|
|
{
|
|
|
|
select_printf ("signalfd %d ready", me->fd);
|
2019-01-15 00:19:37 +08:00
|
|
|
me->read_ready = true;
|
2019-01-14 06:13:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
select_printf ("signalfd %d not ready", me->fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2019-01-15 00:19:37 +08:00
|
|
|
verify_signalfd (select_record *me, fd_set *rfds, fd_set *wfds, fd_set *efds)
|
2019-01-14 06:13:33 +08:00
|
|
|
{
|
|
|
|
return peek_signalfd (me, true);
|
|
|
|
}
|
|
|
|
|
2019-08-16 22:36:06 +08:00
|
|
|
extern HANDLE my_pendingsigs_evt;
|
|
|
|
|
2019-01-14 06:13:33 +08:00
|
|
|
select_record *
|
2019-01-15 00:19:37 +08:00
|
|
|
fhandler_signalfd::select_read (select_stuff *stuff)
|
2019-01-14 06:13:33 +08:00
|
|
|
{
|
2019-01-15 00:19:37 +08:00
|
|
|
select_record *s = stuff->start.next;
|
2019-01-14 06:13:33 +08:00
|
|
|
if (!s->startup)
|
|
|
|
{
|
2019-08-16 22:36:06 +08:00
|
|
|
s->startup = no_startup;
|
2019-01-15 00:19:37 +08:00
|
|
|
s->verify = verify_signalfd;
|
2019-01-14 06:13:33 +08:00
|
|
|
}
|
|
|
|
s->peek = peek_signalfd;
|
2019-08-16 22:36:06 +08:00
|
|
|
s->h = my_pendingsigs_evt; /* wait_sig sets this if signal are pending */
|
2019-01-14 06:13:33 +08:00
|
|
|
s->read_selected = true;
|
2019-01-15 00:19:37 +08:00
|
|
|
s->read_ready = false;
|
2019-01-14 06:13:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2019-01-15 00:19:37 +08:00
|
|
|
fhandler_signalfd::select_write (select_stuff *stuff)
|
2019-01-14 06:13:33 +08:00
|
|
|
{
|
2019-01-15 00:19:37 +08:00
|
|
|
select_record *s = stuff->start.next;
|
2019-01-14 06:13:33 +08:00
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->peek = NULL;
|
|
|
|
s->write_selected = false;
|
|
|
|
s->write_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
2019-01-15 00:19:37 +08:00
|
|
|
fhandler_signalfd::select_except (select_stuff *stuff)
|
2019-01-14 06:13:33 +08:00
|
|
|
{
|
2019-01-15 00:19:37 +08:00
|
|
|
select_record *s = stuff->start.next;
|
2019-01-14 06:13:33 +08:00
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->peek = NULL;
|
|
|
|
s->except_selected = false;
|
|
|
|
s->except_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
2019-01-16 05:02:33 +08:00
|
|
|
|
2019-02-24 06:02:44 +08:00
|
|
|
static int
|
|
|
|
peek_timerfd (select_record *me, bool)
|
|
|
|
{
|
|
|
|
if (WaitForSingleObject (me->h, 0) == WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
select_printf ("timerfd %d ready", me->fd);
|
|
|
|
me->read_ready = true;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
select_printf ("timerfd %d not ready", me->fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
verify_timerfd (select_record *me, fd_set *rfds, fd_set *wfds,
|
|
|
|
fd_set *efds)
|
|
|
|
{
|
|
|
|
return peek_timerfd (me, true);
|
|
|
|
}
|
|
|
|
|
2019-01-16 05:02:33 +08:00
|
|
|
select_record *
|
|
|
|
fhandler_timerfd::select_read (select_stuff *stuff)
|
|
|
|
{
|
|
|
|
select_record *s = stuff->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
2019-02-24 06:02:44 +08:00
|
|
|
s->verify = verify_timerfd;
|
2019-01-16 05:02:33 +08:00
|
|
|
}
|
|
|
|
s->h = get_timerfd_handle ();
|
2019-02-24 06:02:44 +08:00
|
|
|
s->peek = peek_timerfd;
|
2019-01-16 05:02:33 +08:00
|
|
|
s->read_selected = true;
|
2019-02-24 06:02:44 +08:00
|
|
|
s->read_ready = false;
|
2019-01-16 05:02:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_timerfd::select_write (select_stuff *stuff)
|
|
|
|
{
|
|
|
|
select_record *s = stuff->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->peek = NULL;
|
|
|
|
s->write_selected = false;
|
|
|
|
s->write_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_timerfd::select_except (select_stuff *stuff)
|
|
|
|
{
|
|
|
|
select_record *s = stuff->start.next;
|
|
|
|
if (!s->startup)
|
|
|
|
{
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->peek = NULL;
|
|
|
|
s->except_selected = false;
|
|
|
|
s->except_ready = false;
|
|
|
|
return s;
|
|
|
|
}
|