2000-02-18 03:38:33 +08:00
|
|
|
/* select.cc
|
|
|
|
|
2004-02-09 12:04:24 +08:00
|
|
|
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
Written by Christopher Faylor of Cygnus Solutions
|
|
|
|
cgf@cygnus.com
|
|
|
|
|
|
|
|
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. */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The following line means that the BSD socket
|
|
|
|
* definitions for fd_set, FD_ISSET etc. are used in this
|
|
|
|
* file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define __INSIDE_CYGWIN_NET__
|
|
|
|
|
2000-08-03 00:28:18 +08:00
|
|
|
#include "winsup.h"
|
2000-02-18 03:38:33 +08:00
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
2000-08-03 00:28:18 +08:00
|
|
|
#include <wingdi.h>
|
|
|
|
#include <winuser.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
#include <netdb.h>
|
|
|
|
#include <unistd.h>
|
2004-09-03 09:32:02 +08:00
|
|
|
#include <limits.h>
|
2001-03-21 03:50:28 +08:00
|
|
|
#define USE_SYS_TYPES_FD_SET
|
2000-02-18 03:38:33 +08:00
|
|
|
#include <winsock.h>
|
|
|
|
#include "select.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"
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "dtable.h"
|
2001-04-19 05:10:15 +08:00
|
|
|
#include "cygheap.h"
|
2000-08-22 13:10:20 +08:00
|
|
|
#include "sigproc.h"
|
|
|
|
#include "perthread.h"
|
2000-09-08 00:23:51 +08:00
|
|
|
#include "tty.h"
|
2002-08-02 00:20:31 +08:00
|
|
|
#include "cygthread.h"
|
2004-09-03 09:32:02 +08:00
|
|
|
#include "ntdll.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).
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef long fd_mask;
|
|
|
|
#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) \
|
2002-09-22 11:38:57 +08:00
|
|
|
((unsigned) (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) \
|
|
|
|
bzero ((caddr_t)(p), sizeof_fd_set ((n)))
|
|
|
|
|
2000-08-09 10:33:47 +08:00
|
|
|
#define allocfd_set(n) ((fd_set *) memset (alloca (sizeof_fd_set (n)), 0, sizeof_fd_set (n)))
|
2000-02-18 03:38:33 +08:00
|
|
|
#define copyfd_set(to, from, n) memcpy (to, from, sizeof_fd_set (n));
|
|
|
|
|
|
|
|
#define set_handle_or_return_if_not_open(h, s) \
|
|
|
|
h = (s)->fh->get_handle (); \
|
2001-04-19 05:10:15 +08:00
|
|
|
if (cygheap->fdtab.not_open ((s)->fd)) \
|
2000-02-18 03:38:33 +08:00
|
|
|
{ \
|
2001-11-04 10:31:58 +08:00
|
|
|
(s)->saw_error = true; \
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EBADF); \
|
2000-02-18 03:38:33 +08:00
|
|
|
return -1; \
|
|
|
|
} \
|
|
|
|
|
|
|
|
/* The main select code.
|
|
|
|
*/
|
2003-03-10 04:10:25 +08:00
|
|
|
extern "C" int
|
2000-08-09 10:33:47 +08:00
|
|
|
cygwin_select (int maxfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|
|
|
struct timeval *to)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_stuff sel;
|
2000-08-09 10:33:47 +08:00
|
|
|
fd_set *dummy_readfds = allocfd_set (maxfds);
|
|
|
|
fd_set *dummy_writefds = allocfd_set (maxfds);
|
|
|
|
fd_set *dummy_exceptfds = allocfd_set (maxfds);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-08-09 10:33:47 +08:00
|
|
|
select_printf ("%d, %p, %p, %p, %p", maxfds, readfds, writefds, exceptfds, to);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (!readfds)
|
2000-08-09 10:33:47 +08:00
|
|
|
readfds = dummy_readfds;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!writefds)
|
2000-08-09 10:33:47 +08:00
|
|
|
writefds = dummy_writefds;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!exceptfds)
|
2000-08-09 10:33:47 +08:00
|
|
|
exceptfds = dummy_exceptfds;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2000-08-09 10:33:47 +08:00
|
|
|
for (int i = 0; i < maxfds; i++)
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!sel.test_and_set (i, readfds, writefds, exceptfds))
|
|
|
|
{
|
|
|
|
select_printf ("aborting due to test_and_set error");
|
|
|
|
return -1; /* Invalid fd, maybe? */
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert to milliseconds or INFINITE if to == NULL */
|
|
|
|
DWORD ms = to ? (to->tv_sec * 1000) + (to->tv_usec / 1000) : INFINITE;
|
|
|
|
if (ms == 0 && to->tv_usec)
|
|
|
|
ms = 1; /* At least 1 ms granularity */
|
|
|
|
|
|
|
|
if (to)
|
|
|
|
select_printf ("to->tv_sec %d, to->tv_usec %d, ms %d", to->tv_sec, to->tv_usec, ms);
|
|
|
|
else
|
|
|
|
select_printf ("to NULL, ms %x", ms);
|
|
|
|
|
2000-04-04 02:15:01 +08:00
|
|
|
select_printf ("sel.always_ready %d", sel.always_ready);
|
2000-02-18 03:38:33 +08:00
|
|
|
|
2001-08-27 23:59:26 +08:00
|
|
|
int timeout = 0;
|
|
|
|
/* Allocate some fd_set structures using the number of fds as a guide. */
|
|
|
|
fd_set *r = allocfd_set (maxfds);
|
|
|
|
fd_set *w = allocfd_set (maxfds);
|
|
|
|
fd_set *e = allocfd_set (maxfds);
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Degenerate case. No fds to wait for. Just wait. */
|
2000-04-04 02:15:01 +08:00
|
|
|
if (sel.start.next == NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-08-29 04:39:22 +08:00
|
|
|
if (WaitForSingleObject (signal_arrived, ms) == WAIT_OBJECT_0)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("signal received");
|
|
|
|
set_sig_errno (EINTR);
|
|
|
|
return -1;
|
|
|
|
}
|
2001-08-27 23:59:26 +08:00
|
|
|
timeout = 1;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
2001-08-27 23:59:26 +08:00
|
|
|
else if (sel.always_ready || ms == 0)
|
2000-08-25 05:19:14 +08:00
|
|
|
/* Don't bother waiting. */;
|
2001-08-27 23:59:26 +08:00
|
|
|
else if ((timeout = sel.wait (r, w, e, ms) < 0))
|
2000-08-09 10:33:47 +08:00
|
|
|
return -1; /* some kind of error */
|
|
|
|
|
2001-08-31 13:06:14 +08:00
|
|
|
sel.cleanup ();
|
2000-08-09 10:33:47 +08:00
|
|
|
copyfd_set (readfds, r, maxfds);
|
|
|
|
copyfd_set (writefds, w, maxfds);
|
|
|
|
copyfd_set (exceptfds, e, maxfds);
|
2001-08-27 23:59:26 +08:00
|
|
|
return timeout ? 0 : sel.poll (readfds, writefds, exceptfds);
|
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. */
|
|
|
|
select_stuff::~select_stuff ()
|
|
|
|
{
|
|
|
|
cleanup ();
|
|
|
|
select_record *s = &start;
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a record to the select chain */
|
|
|
|
int
|
|
|
|
select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds,
|
|
|
|
fd_set *exceptfds)
|
|
|
|
{
|
|
|
|
select_record *s = NULL;
|
2001-04-19 05:10:15 +08:00
|
|
|
if (UNIX_FD_ISSET (i, readfds) && (s = cygheap->fdtab.select_read (i, s)) == NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0; /* error */
|
2001-04-19 05:10:15 +08:00
|
|
|
if (UNIX_FD_ISSET (i, writefds) && (s = cygheap->fdtab.select_write (i, s)) == NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0; /* error */
|
2001-04-19 05:10:15 +08:00
|
|
|
if (UNIX_FD_ISSET (i, exceptfds) && (s = cygheap->fdtab.select_except (i, s)) == NULL)
|
2000-02-18 03:38:33 +08:00
|
|
|
return 0; /* error */
|
|
|
|
if (s == NULL)
|
|
|
|
return 1; /* nothing to do */
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
if (s->windows_handle || s->windows_handle || s->windows_handle)
|
2001-11-04 10:31:58 +08:00
|
|
|
windows_used = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
s->next = start.next;
|
|
|
|
start.next = s;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The heart of select. Waits for an fd to do something interesting. */
|
|
|
|
int
|
|
|
|
select_stuff::wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
|
|
|
|
DWORD ms)
|
|
|
|
{
|
|
|
|
int wait_ret;
|
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;
|
|
|
|
int m = 0;
|
2001-08-27 23:59:26 +08:00
|
|
|
int res = 0;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
w4[m++] = signal_arrived; /* Always wait for the arrival of a signal. */
|
|
|
|
/* Loop through the select chain, starting up anything appropriate and
|
|
|
|
counting the number of active fds. */
|
|
|
|
while ((s = s->next))
|
|
|
|
{
|
2004-08-10 23:05:37 +08:00
|
|
|
if (m >= MAXIMUM_WAIT_OBJECTS)
|
2000-08-11 03:33:54 +08:00
|
|
|
{
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EINVAL);
|
2000-08-11 03:33:54 +08:00
|
|
|
return -1;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!s->startup (s, this))
|
|
|
|
{
|
|
|
|
__seterrno ();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (s->h == NULL)
|
|
|
|
continue;
|
|
|
|
for (int i = 1; i < m; i++)
|
|
|
|
if (w4[i] == s->h)
|
|
|
|
goto next_while;
|
|
|
|
w4[m++] = s->h;
|
|
|
|
next_while:
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD start_time = GetTickCount (); /* Record the current time for later use. */
|
|
|
|
|
2000-08-09 10:33:47 +08:00
|
|
|
debug_printf ("m %d, ms %u", m, ms);
|
2000-02-18 03:38:33 +08:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!windows_used)
|
|
|
|
wait_ret = WaitForMultipleObjects (m, w4, FALSE, ms);
|
|
|
|
else
|
|
|
|
wait_ret = MsgWaitForMultipleObjects (m, w4, FALSE, ms, QS_ALLINPUT);
|
|
|
|
|
|
|
|
switch (wait_ret)
|
|
|
|
{
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
select_printf ("signal received");
|
|
|
|
set_sig_errno (EINTR);
|
|
|
|
return -1;
|
|
|
|
case WAIT_FAILED:
|
|
|
|
select_printf ("WaitForMultipleObjects failed");
|
|
|
|
__seterrno ();
|
|
|
|
return -1;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
select_printf ("timed out");
|
2001-08-27 23:59:26 +08:00
|
|
|
res = 1;
|
2000-02-18 03:38:33 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_printf ("woke up. wait_ret %d. verifying", wait_ret);
|
|
|
|
s = &start;
|
2003-12-08 06:37:12 +08:00
|
|
|
bool gotone = false;
|
2001-11-05 08:29:27 +08:00
|
|
|
/* Some types of object (e.g., consoles) wake up on "inappropriate" events
|
2001-11-05 14:09:15 +08:00
|
|
|
like mouse movements. The verify function will detect these situations.
|
2001-11-05 08:29:27 +08:00
|
|
|
If it returns false, then this wakeup was a false alarm and we should go
|
|
|
|
back to waiting. */
|
2000-02-18 03:38:33 +08:00
|
|
|
while ((s = s->next))
|
|
|
|
if (s->saw_error)
|
|
|
|
return -1; /* Somebody detected an error */
|
|
|
|
else if ((((wait_ret >= m && s->windows_handle) || s->h == w4[wait_ret])) &&
|
2000-08-09 10:33:47 +08:00
|
|
|
s->verify (s, readfds, writefds, exceptfds))
|
2001-11-04 10:31:58 +08:00
|
|
|
gotone = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
select_printf ("gotone %d", gotone);
|
|
|
|
if (gotone)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
if (ms == INFINITE)
|
|
|
|
{
|
|
|
|
select_printf ("looping");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
select_printf ("recalculating ms");
|
|
|
|
|
|
|
|
DWORD now = GetTickCount ();
|
|
|
|
if (now > (start_time + ms))
|
|
|
|
{
|
|
|
|
select_printf ("timed out after verification");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
ms -= (now - start_time);
|
|
|
|
start_time = now;
|
|
|
|
select_printf ("ms now %u", ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
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);
|
* 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
|
|
|
if (me->except_on_write && me->fh->is_socket ())
|
2004-04-10 21:45:10 +08:00
|
|
|
((fhandler_socket *) me->fh)->connect_state (connected);
|
2000-02-18 03:38:33 +08:00
|
|
|
ready++;
|
|
|
|
}
|
2002-07-06 19:16:07 +08:00
|
|
|
if ((me->except_selected || me->except_on_write) && me->except_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2002-07-06 19:16:07 +08:00
|
|
|
if (me->except_on_write) /* Only on sockets */
|
2002-09-30 23:17:44 +08:00
|
|
|
{
|
2002-07-06 19:16:07 +08:00
|
|
|
UNIX_FD_SET (me->fd, writefds);
|
* 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
|
|
|
if (me->fh->is_socket ())
|
2004-04-10 21:45:10 +08:00
|
|
|
((fhandler_socket *) me->fh)->connect_state (connected);
|
2002-09-30 23:17:44 +08:00
|
|
|
}
|
2002-07-06 19:16:07 +08:00
|
|
|
if (me->except_selected)
|
|
|
|
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))
|
|
|
|
n += (!s->peek || s->peek (s, true)) ?
|
|
|
|
set_bits (s, readfds, writefds, exceptfds) : 0;
|
|
|
|
select_printf ("returning %d", n);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
int n = 0;
|
|
|
|
int gotone = 0;
|
|
|
|
fhandler_base *fh = s->fh;
|
|
|
|
|
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, s);
|
|
|
|
|
2001-11-05 08:29:27 +08:00
|
|
|
/* pipes require a guard mutex to guard against the situation where multiple
|
|
|
|
readers are attempting to read from the same pipe. In this scenario, it
|
|
|
|
is possible for PeekNamedPipe to report available data to two readers but
|
|
|
|
only one will actually get the data. This will result in the other reader
|
|
|
|
entering fhandler_base::raw_read and blocking indefinitely in an interruptible
|
|
|
|
state. This causes things like "make -j2" to hang. So, for the non-select case
|
|
|
|
we use the pipe mutex, if it is available. */
|
2001-11-04 10:31:58 +08:00
|
|
|
HANDLE guard_mutex = from_select ? NULL : fh->get_guard ();
|
2001-11-05 08:29:27 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Don't perform complicated tests if we don't need to. */
|
|
|
|
if (!s->read_selected && !s->except_selected)
|
|
|
|
goto out;
|
|
|
|
|
2000-03-12 14:29:54 +08:00
|
|
|
if (s->read_selected)
|
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
|
|
|
|
2000-11-09 10:03:33 +08:00
|
|
|
switch (fh->get_device ())
|
2000-03-12 14:29:54 +08:00
|
|
|
{
|
2000-11-09 10:03:33 +08:00
|
|
|
case FH_PTYM:
|
|
|
|
case FH_TTYM:
|
2002-12-11 12:00:04 +08:00
|
|
|
if (((fhandler_pty_master *) fh)->need_nl)
|
2000-11-09 10:03:33 +08:00
|
|
|
{
|
2001-11-05 08:29:27 +08:00
|
|
|
gotone = s->read_ready = true;
|
2000-11-09 10:03:33 +08:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
|
|
|
if (fh->bg_check (SIGTTIN) <= bg_eof)
|
|
|
|
{
|
2001-11-05 08:29:27 +08:00
|
|
|
gotone = s->read_ready = true;
|
2001-09-25 05:50:44 +08:00
|
|
|
goto out;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
2001-09-23 00:55:02 +08:00
|
|
|
if (fh->get_device () == FH_PIPEW)
|
2004-09-03 09:32:02 +08:00
|
|
|
select_printf ("%s, select for read/except on write end of pipe",
|
|
|
|
fh->get_name ());
|
2001-09-25 06:49:12 +08:00
|
|
|
else if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
|
|
|
|
{
|
|
|
|
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
|
|
|
|
n = -1;
|
|
|
|
}
|
2001-11-03 13:42:21 +08:00
|
|
|
else if (!n || !guard_mutex)
|
2002-02-15 05:20:06 +08:00
|
|
|
/* no guard mutex or nothing to read from the pipe. */;
|
2001-11-03 13:42:21 +08:00
|
|
|
else if (WaitForSingleObject (guard_mutex, 0) != WAIT_OBJECT_0)
|
|
|
|
{
|
|
|
|
select_printf ("%s, couldn't get mutex %p, %E", fh->get_name (),
|
|
|
|
guard_mutex);
|
|
|
|
n = 0;
|
|
|
|
}
|
|
|
|
else
|
2001-09-23 00:55:02 +08:00
|
|
|
{
|
2001-11-03 11:32:27 +08:00
|
|
|
/* Now that we have the mutex, make sure that no one else has snuck
|
2001-11-03 13:42:21 +08:00
|
|
|
in and grabbed the data that we originally saw. */
|
2001-11-03 11:32:27 +08:00
|
|
|
if (!PeekNamedPipe (h, NULL, 0, NULL, (DWORD *) &n, NULL))
|
|
|
|
{
|
|
|
|
select_printf ("%s, PeekNamedPipe failed, %E", fh->get_name ());
|
|
|
|
n = -1;
|
|
|
|
}
|
|
|
|
if (n <= 0)
|
|
|
|
ReleaseMutex (guard_mutex); /* Oops. We lost the race. */
|
2001-09-23 00:55:02 +08:00
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (n < 0)
|
|
|
|
{
|
2001-11-05 08:29:27 +08:00
|
|
|
fh->set_eof (); /* Flag that other end of pipe is gone */
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("%s, n %d", fh->get_name (), n);
|
|
|
|
if (s->except_selected)
|
2001-11-04 10:31:58 +08:00
|
|
|
gotone += s->except_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (s->read_selected)
|
2001-11-04 10:31:58 +08:00
|
|
|
gotone += s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
if (n > 0 && s->read_selected)
|
|
|
|
{
|
2004-09-03 09:32:02 +08:00
|
|
|
select_printf ("%s, ready for read: avail %d", fh->get_name (), n);
|
2001-11-04 10:31:58 +08:00
|
|
|
gotone += s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
if (!gotone && s->fh->hit_eof ())
|
|
|
|
{
|
|
|
|
select_printf ("%s, saw EOF", fh->get_name ());
|
|
|
|
if (s->except_selected)
|
2004-09-03 09:32:02 +08:00
|
|
|
gotone += s->except_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (s->read_selected)
|
2001-11-04 10:31:58 +08:00
|
|
|
gotone += s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
2004-09-03 09:32:02 +08:00
|
|
|
if (s->write_selected)
|
|
|
|
{
|
|
|
|
if (s->write_ready)
|
2004-09-12 11:47:57 +08:00
|
|
|
{
|
|
|
|
select_printf ("%s, already ready for write", fh->get_name ());
|
|
|
|
gotone++;
|
|
|
|
}
|
2004-09-03 09:32:02 +08:00
|
|
|
/* Do we need to do anything about SIGTTOU here? */
|
|
|
|
else if (fh->get_device () == FH_PIPER)
|
|
|
|
select_printf ("%s, select for write on read end of pipe",
|
|
|
|
fh->get_name ());
|
|
|
|
else
|
2004-09-12 11:47:57 +08:00
|
|
|
{
|
|
|
|
/* We don't worry about the guard mutex, because that only applies
|
|
|
|
when from_select is false, and peek_pipe is never called that
|
|
|
|
way for writes. */
|
|
|
|
|
|
|
|
IO_STATUS_BLOCK iosb = {0};
|
|
|
|
FILE_PIPE_LOCAL_INFORMATION fpli = {0};
|
|
|
|
|
|
|
|
if (NtQueryInformationFile (h,
|
|
|
|
&iosb,
|
|
|
|
&fpli,
|
|
|
|
sizeof (fpli),
|
|
|
|
FilePipeLocalInformation))
|
|
|
|
{
|
|
|
|
/* If NtQueryInformationFile fails, optimistically assume the
|
|
|
|
pipe is writable. This could happen on Win9x, because
|
|
|
|
NtQueryInformationFile is not available, or if we somehow
|
|
|
|
inherit a pipe that doesn't permit FILE_READ_ATTRIBUTES
|
|
|
|
access on the write end. */
|
|
|
|
select_printf ("%s, NtQueryInformationFile failed",
|
|
|
|
fh->get_name ());
|
|
|
|
gotone += s->write_ready = true;
|
|
|
|
}
|
|
|
|
/* Ensure that enough space is available for atomic writes,
|
|
|
|
as required by POSIX. Subsequent writes with size > PIPE_BUF
|
|
|
|
can still block, but most (all?) UNIX variants seem to work
|
|
|
|
this way (e.g., BSD, Linux, Solaris). */
|
|
|
|
else if (fpli.WriteQuotaAvailable >= PIPE_BUF)
|
|
|
|
{
|
|
|
|
select_printf ("%s, ready for write: size %lu, avail %lu",
|
|
|
|
fh->get_name (),
|
|
|
|
fpli.OutboundQuota,
|
|
|
|
fpli.WriteQuotaAvailable);
|
|
|
|
gotone += s->write_ready = true;
|
|
|
|
}
|
|
|
|
/* 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. */
|
|
|
|
else if (fpli.OutboundQuota < PIPE_BUF &&
|
|
|
|
fpli.WriteQuotaAvailable == fpli.OutboundQuota)
|
|
|
|
{
|
|
|
|
select_printf ("%s, tiny pipe: size %lu, avail %lu",
|
|
|
|
fh->get_name (),
|
|
|
|
fpli.OutboundQuota,
|
|
|
|
fpli.WriteQuotaAvailable);
|
|
|
|
gotone += s->write_ready = true;
|
|
|
|
}
|
|
|
|
}
|
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);
|
|
|
|
|
|
|
|
struct pipeinf
|
|
|
|
{
|
2002-08-02 00:20:31 +08:00
|
|
|
cygthread *thread;
|
2003-12-08 06:37:12 +08:00
|
|
|
bool stop_thread_pipe;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *start;
|
|
|
|
};
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_pipe (void *arg)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
pipeinf *pi = (pipeinf *) arg;
|
2003-12-08 06:37:12 +08:00
|
|
|
bool gotone = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
select_record *s = pi->start;
|
|
|
|
while ((s = s->next))
|
|
|
|
if (s->startup == start_thread_pipe)
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
if (peek_pipe (s, true))
|
|
|
|
gotone = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (pi->stop_thread_pipe)
|
|
|
|
{
|
|
|
|
select_printf ("stopping");
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
2000-05-19 02:32:05 +08:00
|
|
|
/* Paranoid check */
|
|
|
|
if (pi->stop_thread_pipe)
|
|
|
|
{
|
|
|
|
select_printf ("stopping from outer loop");
|
|
|
|
break;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
if (gotone)
|
|
|
|
break;
|
|
|
|
Sleep (10);
|
|
|
|
}
|
|
|
|
out:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
start_thread_pipe (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
* 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
|
|
|
if (stuff->device_specific_pipe)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
* 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
|
|
|
me->h = *((pipeinf *) stuff->device_specific_pipe)->thread;
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
pipeinf *pi = new pipeinf;
|
|
|
|
pi->start = &stuff->start;
|
2003-12-08 06:37:12 +08:00
|
|
|
pi->stop_thread_pipe = false;
|
2002-12-11 12:00:04 +08:00
|
|
|
pi->thread = new cygthread (thread_pipe, (LPVOID) pi, "select_pipe");
|
2002-08-02 00:20:31 +08:00
|
|
|
me->h = *pi->thread;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (!me->h)
|
|
|
|
return 0;
|
* 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
|
|
|
stuff->device_specific_pipe = (void *) pi;
|
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
|
|
|
{
|
* 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
|
|
|
pipeinf *pi = (pipeinf *) stuff->device_specific_pipe;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (pi && pi->thread)
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
pi->stop_thread_pipe = true;
|
2002-08-02 00:20:31 +08:00
|
|
|
pi->thread->detach ();
|
2000-02-18 03:38:33 +08:00
|
|
|
delete pi;
|
* 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
|
|
|
stuff->device_specific_pipe = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-11 12:00:04 +08:00
|
|
|
int
|
|
|
|
fhandler_pipe::ready_for_read (int fd, DWORD howlong)
|
|
|
|
{
|
2003-04-23 09:27:51 +08:00
|
|
|
int res;
|
|
|
|
if (howlong)
|
|
|
|
res = true;
|
|
|
|
else
|
|
|
|
res = fhandler_base::ready_for_read (fd, howlong);
|
2002-12-11 12:00:04 +08:00
|
|
|
|
2003-04-23 09:27:51 +08:00
|
|
|
if (res)
|
|
|
|
get_guard ();
|
|
|
|
return res;
|
2002-12-11 12:00:04 +08:00
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
|
|
|
fhandler_pipe::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_pipe::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
2004-09-03 09:32:02 +08:00
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_pipe::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
2004-09-03 09:32:02 +08:00
|
|
|
s = new select_record;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_console (select_record *me, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2000-07-31 01:58:48 +08:00
|
|
|
extern const char * get_nonascii_key (INPUT_RECORD& input_rec, char *);
|
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;
|
|
|
|
|
2001-11-04 10:31:58 +08:00
|
|
|
if (fh->get_readahead_valid ())
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("readahead");
|
2001-11-05 08:29:27 +08:00
|
|
|
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;
|
2000-07-31 01:58:48 +08:00
|
|
|
char tmpbuf[17];
|
2000-02-18 03:38:33 +08:00
|
|
|
set_handle_or_return_if_not_open (h, me);
|
|
|
|
|
|
|
|
for (;;)
|
2001-01-17 22:57:09 +08:00
|
|
|
if (fh->bg_check (SIGTTIN) <= bg_eof)
|
2001-11-05 08:29:27 +08:00
|
|
|
return me->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
else if (!PeekConsoleInput (h, &irec, 1, &events_read) || !events_read)
|
|
|
|
break;
|
|
|
|
else
|
|
|
|
{
|
2002-08-19 12:43:58 +08:00
|
|
|
if (irec.EventType == KEY_EVENT)
|
2001-03-02 09:55:21 +08:00
|
|
|
{
|
2002-08-19 12:43:58 +08:00
|
|
|
if (irec.Event.KeyEvent.bKeyDown
|
|
|
|
&& (irec.Event.KeyEvent.uChar.AsciiChar
|
|
|
|
|| get_nonascii_key (irec, tmpbuf)))
|
2001-11-05 08:29:27 +08:00
|
|
|
return me->read_ready = true;
|
2001-03-02 09:55:21 +08:00
|
|
|
}
|
2002-08-19 12:43:58 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
fh->send_winch_maybe ();
|
|
|
|
if (irec.EventType == MOUSE_EVENT
|
|
|
|
&& fh->mouse_aware ()
|
|
|
|
&& (irec.Event.MouseEvent.dwEventFlags == 0
|
|
|
|
|| irec.Event.MouseEvent.dwEventFlags == DOUBLE_CLICK))
|
|
|
|
return me->read_ready = true;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/* Read and discard the event */
|
|
|
|
ReadConsoleInput (h, &irec, 1, &events_read);
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_console::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_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;
|
|
|
|
s->read_ready = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_console::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_console::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_tty_common::select_read (select_record *s)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
return ((fhandler_pipe *) this)->fhandler_pipe::select_read (s);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_tty_common::select_write (select_record *s)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
return ((fhandler_pipe *) this)->fhandler_pipe::select_write (s);
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_tty_common::select_except (select_record *s)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
return ((fhandler_pipe *) this)->fhandler_pipe::select_except (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)
|
|
|
|
{
|
|
|
|
if (WaitForSingleObject (me->h, 0) == WAIT_OBJECT_0)
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_tty_slave::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
s = new select_record;
|
|
|
|
s->h = input_available_event;
|
|
|
|
s->startup = no_startup;
|
2001-11-02 05:15:53 +08:00
|
|
|
s->peek = peek_pipe;
|
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;
|
2001-03-19 02:05:01 +08:00
|
|
|
s->cleanup = NULL;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *
|
|
|
|
fhandler_dev_null::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_dev_null::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_dev_null::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = no_verify;
|
|
|
|
}
|
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int start_thread_serial (select_record *me, select_stuff *stuff);
|
|
|
|
|
|
|
|
struct serialinf
|
|
|
|
{
|
2002-08-02 00:20:31 +08:00
|
|
|
cygthread *thread;
|
2003-12-08 06:37:12 +08:00
|
|
|
bool stop_thread_serial;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_record *start;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_serial (select_record *s, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
COMSTAT st;
|
|
|
|
|
2002-12-11 12:00:04 +08:00
|
|
|
fhandler_serial *fh = (fhandler_serial *) s->fh;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
if (fh->get_readahead_valid () || fh->overlapped_armed < 0)
|
2001-11-05 08:29:27 +08:00
|
|
|
return s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
select_printf ("fh->overlapped_armed %d", fh->overlapped_armed);
|
|
|
|
|
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, s);
|
|
|
|
int ready = 0;
|
2000-05-13 09:42:53 +08:00
|
|
|
|
|
|
|
if (s->read_selected && s->read_ready || (s->write_selected && s->write_ready))
|
|
|
|
{
|
|
|
|
select_printf ("already ready");
|
|
|
|
ready = 1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
(void) SetCommMask (h, EV_RXCHAR);
|
|
|
|
|
|
|
|
if (!fh->overlapped_armed)
|
|
|
|
{
|
|
|
|
COMSTAT st;
|
|
|
|
|
|
|
|
ResetEvent (fh->io_status.hEvent);
|
|
|
|
|
2001-12-11 08:24:46 +08:00
|
|
|
if (!ClearCommError (h, &fh->ev, &st))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
debug_printf ("ClearCommError");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
else if (st.cbInQue)
|
2001-11-05 08:29:27 +08:00
|
|
|
return s->read_ready = true;
|
2001-12-11 08:24:46 +08:00
|
|
|
else if (WaitCommEvent (h, &fh->ev, &fh->io_status))
|
2001-11-05 08:29:27 +08:00
|
|
|
return s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
else if (GetLastError () == ERROR_IO_PENDING)
|
|
|
|
fh->overlapped_armed = 1;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
debug_printf ("WaitCommEvent");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HANDLE w4[2];
|
|
|
|
DWORD to;
|
|
|
|
|
|
|
|
w4[0] = fh->io_status.hEvent;
|
|
|
|
w4[1] = signal_arrived;
|
|
|
|
to = 10;
|
|
|
|
|
|
|
|
switch (WaitForMultipleObjects (2, w4, FALSE, to))
|
|
|
|
{
|
|
|
|
case WAIT_OBJECT_0:
|
2001-12-11 08:24:46 +08:00
|
|
|
if (!ClearCommError (h, &fh->ev, &st))
|
2000-09-03 12:16:35 +08:00
|
|
|
{
|
|
|
|
debug_printf ("ClearCommError");
|
|
|
|
goto err;
|
|
|
|
}
|
2000-02-18 03:38:33 +08:00
|
|
|
else if (!st.cbInQue)
|
|
|
|
Sleep (to);
|
|
|
|
else
|
|
|
|
{
|
2001-11-05 08:29:27 +08:00
|
|
|
return s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("got something");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WAIT_OBJECT_0 + 1:
|
|
|
|
select_printf ("interrupt");
|
|
|
|
set_sig_errno (EINTR);
|
|
|
|
ready = -1;
|
|
|
|
break;
|
|
|
|
case WAIT_TIMEOUT:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug_printf ("WaitForMultipleObjects");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2000-05-13 09:42:53 +08:00
|
|
|
out:
|
2000-02-18 03:38:33 +08:00
|
|
|
return ready;
|
|
|
|
|
|
|
|
err:
|
|
|
|
if (GetLastError () == ERROR_OPERATION_ABORTED)
|
|
|
|
{
|
|
|
|
select_printf ("operation aborted");
|
|
|
|
return ready;
|
|
|
|
}
|
|
|
|
|
|
|
|
__seterrno ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->saw_error = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("error %E");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD WINAPI
|
|
|
|
thread_serial (void *arg)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
serialinf *si = (serialinf *) arg;
|
2003-12-08 06:37:12 +08:00
|
|
|
bool gotone = false;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
select_record *s = si->start;
|
|
|
|
while ((s = s->next))
|
|
|
|
if (s->startup == start_thread_serial)
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
if (peek_serial (s, true))
|
|
|
|
gotone = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
if (si->stop_thread_serial)
|
|
|
|
{
|
|
|
|
select_printf ("stopping");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (gotone)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_printf ("exiting");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
start_thread_serial (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
* 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
|
|
|
if (stuff->device_specific_serial)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
* 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
|
|
|
me->h = *((serialinf *) stuff->device_specific_serial)->thread;
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
serialinf *si = new serialinf;
|
|
|
|
si->start = &stuff->start;
|
2003-12-08 06:37:12 +08:00
|
|
|
si->stop_thread_serial = false;
|
2002-12-11 12:00:04 +08:00
|
|
|
si->thread = new cygthread (thread_serial, (LPVOID) si, "select_serial");
|
2002-08-02 00:20:31 +08:00
|
|
|
me->h = *si->thread;
|
* 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
|
|
|
stuff->device_specific_serial = (void *) si;
|
2000-02-18 03:38:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-02-21 13:20:38 +08:00
|
|
|
serial_cleanup (select_record *, select_stuff *stuff)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
* 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
|
|
|
serialinf *si = (serialinf *) stuff->device_specific_serial;
|
2000-02-18 03:38:33 +08:00
|
|
|
if (si && si->thread)
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
si->stop_thread_serial = true;
|
2002-08-02 00:20:31 +08:00
|
|
|
si->thread->detach ();
|
2000-02-18 03:38:33 +08:00
|
|
|
delete si;
|
* 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
|
|
|
stuff->device_specific_serial = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_serial::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = start_thread_serial;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
s->cleanup = serial_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;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_serial::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_serial;
|
2000-02-18 03:38:33 +08:00
|
|
|
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 *
|
|
|
|
fhandler_serial::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
s->h = NULL;
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2001-11-04 10:31:58 +08:00
|
|
|
fhandler_base::ready_for_read (int fd, DWORD howlong)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2001-11-02 05:15:53 +08:00
|
|
|
int avail = 0;
|
|
|
|
select_record me (this);
|
|
|
|
me.fd = fd;
|
|
|
|
while (!avail)
|
|
|
|
{
|
|
|
|
(void) select_read (&me);
|
2001-11-04 10:31:58 +08:00
|
|
|
avail = me.read_ready ?: me.peek (&me, false);
|
2001-11-02 05:15:53 +08:00
|
|
|
|
|
|
|
if (fd >= 0 && cygheap->fdtab.not_open (fd))
|
|
|
|
{
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EBADF);
|
2001-11-02 05:15:53 +08:00
|
|
|
avail = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (howlong != INFINITE)
|
|
|
|
{
|
|
|
|
if (!avail)
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EAGAIN);
|
2001-11-02 05:15:53 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WaitForSingleObject (signal_arrived, avail ? 0 : 10) == WAIT_OBJECT_0)
|
|
|
|
{
|
2003-11-29 04:55:59 +08:00
|
|
|
debug_printf ("interrupted");
|
2001-11-09 01:49:52 +08:00
|
|
|
set_sig_errno (EINTR);
|
2001-11-02 05:15:53 +08:00
|
|
|
avail = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-02 07:48:34 +08:00
|
|
|
if (get_guard () && !avail && me.read_ready)
|
|
|
|
ReleaseMutex (get_guard ());
|
|
|
|
|
2001-11-02 05:15:53 +08:00
|
|
|
select_printf ("read_ready %d, avail %d", me.read_ready, avail);
|
|
|
|
return avail;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_base::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
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 *
|
|
|
|
fhandler_base::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
|
|
|
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 *
|
|
|
|
fhandler_base::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct socketinf
|
|
|
|
{
|
2002-08-02 00:20:31 +08:00
|
|
|
cygthread *thread;
|
2000-02-18 03:38:33 +08:00
|
|
|
winsock_fd_set readfds, writefds, exceptfds;
|
|
|
|
SOCKET exitsock;
|
|
|
|
struct sockaddr_in sin;
|
|
|
|
select_record *start;
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2001-11-04 10:31:58 +08:00
|
|
|
peek_socket (select_record *me, bool)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
winsock_fd_set ws_readfds, ws_writefds, ws_exceptfds;
|
2000-02-23 12:07:13 +08:00
|
|
|
struct timeval tv = {0, 0};
|
2000-02-18 03:38:33 +08:00
|
|
|
WINSOCK_FD_ZERO (&ws_readfds);
|
|
|
|
WINSOCK_FD_ZERO (&ws_writefds);
|
|
|
|
WINSOCK_FD_ZERO (&ws_exceptfds);
|
|
|
|
|
|
|
|
HANDLE h;
|
|
|
|
set_handle_or_return_if_not_open (h, me);
|
|
|
|
select_printf ("considering handle %p", h);
|
|
|
|
|
2002-07-06 02:26:23 +08:00
|
|
|
if (me->read_selected && !me->read_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("adding read fd_set %s, fd %d", me->fh->get_name (),
|
|
|
|
me->fd);
|
|
|
|
WINSOCK_FD_SET (h, &ws_readfds);
|
|
|
|
}
|
2002-07-06 02:26:23 +08:00
|
|
|
if (me->write_selected && !me->write_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("adding write fd_set %s, fd %d", me->fh->get_name (),
|
|
|
|
me->fd);
|
|
|
|
WINSOCK_FD_SET (h, &ws_writefds);
|
|
|
|
}
|
2002-07-06 19:16:07 +08:00
|
|
|
if ((me->except_selected || me->except_on_write) && !me->except_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
select_printf ("adding except fd_set %s, fd %d", me->fh->get_name (),
|
|
|
|
me->fd);
|
|
|
|
WINSOCK_FD_SET (h, &ws_exceptfds);
|
|
|
|
}
|
2002-07-06 02:26:23 +08:00
|
|
|
int r;
|
|
|
|
if ((me->read_selected && !me->read_ready)
|
|
|
|
|| (me->write_selected && !me->write_ready)
|
2002-07-06 19:16:07 +08:00
|
|
|
|| ((me->except_selected || me->except_on_write) && !me->except_ready))
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
2002-07-06 02:26:23 +08:00
|
|
|
r = WINSOCK_SELECT (0, &ws_readfds, &ws_writefds, &ws_exceptfds, &tv);
|
|
|
|
select_printf ("WINSOCK_SELECT returned %d", r);
|
|
|
|
if (r == -1)
|
|
|
|
{
|
|
|
|
select_printf ("error %d", WSAGetLastError ());
|
|
|
|
set_winsock_errno ();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (WINSOCK_FD_ISSET (h, &ws_readfds) || (me->read_selected && me->read_ready))
|
|
|
|
me->read_ready = true;
|
|
|
|
if (WINSOCK_FD_ISSET (h, &ws_writefds) || (me->write_selected && me->write_ready))
|
|
|
|
me->write_ready = true;
|
2002-07-06 19:16:07 +08:00
|
|
|
if (WINSOCK_FD_ISSET (h, &ws_exceptfds) || ((me->except_selected || me->except_on_write) && me->except_ready))
|
2002-07-06 02:26:23 +08:00
|
|
|
me->except_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
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)
|
|
|
|
{
|
2002-12-11 12:00:04 +08:00
|
|
|
socketinf *si = (socketinf *) arg;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
select_printf ("stuff_start %p", &si->start);
|
|
|
|
int r = WINSOCK_SELECT (0, &si->readfds, &si->writefds, &si->exceptfds, NULL);
|
|
|
|
select_printf ("Win32 select returned %d", r);
|
|
|
|
if (r == -1)
|
|
|
|
select_printf ("error %d", WSAGetLastError ());
|
|
|
|
select_record *s = si->start;
|
|
|
|
while ((s = s->next))
|
|
|
|
if (s->startup == start_thread_socket)
|
|
|
|
{
|
|
|
|
HANDLE h = s->fh->get_handle ();
|
|
|
|
select_printf ("s %p, testing fd %d (%s)", s, s->fd, s->fh->get_name ());
|
|
|
|
if (WINSOCK_FD_ISSET (h, &si->readfds))
|
|
|
|
{
|
|
|
|
select_printf ("read_ready");
|
2001-11-04 10:31:58 +08:00
|
|
|
s->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
if (WINSOCK_FD_ISSET (h, &si->writefds))
|
|
|
|
{
|
|
|
|
select_printf ("write_ready");
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
if (WINSOCK_FD_ISSET (h, &si->exceptfds))
|
|
|
|
{
|
|
|
|
select_printf ("except_ready");
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WINSOCK_FD_ISSET (si->exitsock, &si->readfds))
|
|
|
|
select_printf ("saw exitsock read");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" unsigned long htonl (unsigned long);
|
|
|
|
|
|
|
|
static int
|
|
|
|
start_thread_socket (select_record *me, select_stuff *stuff)
|
|
|
|
{
|
|
|
|
socketinf *si;
|
|
|
|
|
* 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
|
|
|
if ((si = (socketinf *) 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
si = new socketinf;
|
|
|
|
WINSOCK_FD_ZERO (&si->readfds);
|
|
|
|
WINSOCK_FD_ZERO (&si->writefds);
|
|
|
|
WINSOCK_FD_ZERO (&si->exceptfds);
|
|
|
|
select_record *s = &stuff->start;
|
|
|
|
while ((s = s->next))
|
|
|
|
if (s->startup == start_thread_socket)
|
|
|
|
{
|
|
|
|
HANDLE h = s->fh->get_handle ();
|
|
|
|
select_printf ("Handle %p", h);
|
2002-07-06 02:26:23 +08:00
|
|
|
if (s->read_selected && !s->read_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
WINSOCK_FD_SET (h, &si->readfds);
|
|
|
|
select_printf ("Added to readfds");
|
|
|
|
}
|
2002-07-06 02:26:23 +08:00
|
|
|
if (s->write_selected && !s->write_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
WINSOCK_FD_SET (h, &si->writefds);
|
|
|
|
select_printf ("Added to writefds");
|
|
|
|
}
|
2002-07-06 19:16:07 +08:00
|
|
|
if ((s->except_selected || s->except_on_write) && !s->except_ready)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
|
|
|
WINSOCK_FD_SET (h, &si->exceptfds);
|
|
|
|
select_printf ("Added to exceptfds");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((si->exitsock = socket (PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
|
|
|
|
{
|
|
|
|
set_winsock_errno ();
|
|
|
|
select_printf ("cannot create socket, %E");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Allow rapid reuse of the port. */
|
|
|
|
int tmp = 1;
|
|
|
|
(void) setsockopt (si->exitsock, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
|
|
|
|
|
2002-09-22 11:38:57 +08:00
|
|
|
int sin_len = sizeof (si->sin);
|
2000-02-18 03:38:33 +08:00
|
|
|
memset (&si->sin, 0, sizeof (si->sin));
|
|
|
|
si->sin.sin_family = AF_INET;
|
|
|
|
si->sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
|
|
|
|
if (bind (si->exitsock, (struct sockaddr *) &si->sin, sizeof (si->sin)) < 0)
|
|
|
|
{
|
|
|
|
select_printf ("cannot bind socket, %E");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getsockname (si->exitsock, (struct sockaddr *) &si->sin, &sin_len) < 0)
|
|
|
|
{
|
|
|
|
select_printf ("getsockname error");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (listen (si->exitsock, 1))
|
|
|
|
{
|
|
|
|
select_printf ("listen failed, %E");
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_printf ("exitsock %p", si->exitsock);
|
|
|
|
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->readfds);
|
|
|
|
WINSOCK_FD_SET ((HANDLE) si->exitsock, &si->exceptfds);
|
* 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
|
|
|
stuff->device_specific_socket = (void *) si;
|
2000-02-18 03:38:33 +08:00
|
|
|
si->start = &stuff->start;
|
|
|
|
select_printf ("stuff_start %p", &stuff->start);
|
2002-12-11 12:00:04 +08:00
|
|
|
si->thread = new cygthread (thread_socket, (LPVOID) si, "select_socket");
|
2002-08-02 00:20:31 +08:00
|
|
|
me->h = *si->thread;
|
|
|
|
return 1;
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
err:
|
|
|
|
set_winsock_errno ();
|
|
|
|
closesocket (si->exitsock);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-02-21 13:20:38 +08:00
|
|
|
socket_cleanup (select_record *, select_stuff *stuff)
|
2000-02-18 03:38:33 +08:00
|
|
|
{
|
* 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
|
|
|
socketinf *si = (socketinf *) stuff->device_specific_socket;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("si %p si->thread %p", si, si ? si->thread : NULL);
|
|
|
|
if (si && si->thread)
|
|
|
|
{
|
|
|
|
select_printf ("connection to si->exitsock %p", si->exitsock);
|
|
|
|
SOCKET s = socket (AF_INET, SOCK_STREAM, 0);
|
2001-04-15 06:11:03 +08:00
|
|
|
|
|
|
|
/* Set LINGER with 0 timeout for hard close */
|
|
|
|
struct linger tmp = {1, 0}; /* On, 0 delay */
|
2002-09-22 11:38:57 +08:00
|
|
|
(void) setsockopt (s, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof (tmp));
|
|
|
|
(void) setsockopt (si->exitsock, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof (tmp));
|
2001-04-15 06:11:03 +08:00
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
/* Connecting to si->exitsock will cause any executing select to wake
|
|
|
|
up. When this happens then the exitsock condition will cause the
|
|
|
|
thread to terminate. */
|
|
|
|
if (connect (s, (struct sockaddr *) &si->sin, sizeof (si->sin)) < 0)
|
|
|
|
{
|
|
|
|
set_winsock_errno ();
|
|
|
|
select_printf ("connect failed");
|
|
|
|
/* FIXME: now what? */
|
|
|
|
}
|
2001-04-15 06:11:03 +08:00
|
|
|
shutdown (s, SD_BOTH);
|
2000-02-18 03:38:33 +08:00
|
|
|
closesocket (s);
|
|
|
|
|
|
|
|
/* Wait for thread to go away */
|
2002-08-02 00:20:31 +08:00
|
|
|
si->thread->detach ();
|
2001-04-15 06:11:03 +08:00
|
|
|
shutdown (si->exitsock, SD_BOTH);
|
2000-02-18 03:38:33 +08:00
|
|
|
closesocket (si->exitsock);
|
* 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
|
|
|
stuff->device_specific_socket = NULL;
|
2000-02-18 03:38:33 +08:00
|
|
|
delete si;
|
|
|
|
}
|
|
|
|
select_printf ("returning");
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_socket::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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 *
|
|
|
|
fhandler_socket::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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;
|
2004-04-10 21:45:10 +08:00
|
|
|
if (connect_state () == connect_pending)
|
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 *
|
|
|
|
fhandler_socket::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2000-05-13 09:42:53 +08:00
|
|
|
|
|
|
|
if (me->read_selected && me->read_ready)
|
|
|
|
return 1;
|
|
|
|
|
2000-02-18 03:38:33 +08:00
|
|
|
if (PeekMessage (&m, (HWND) h, 0, 0, PM_NOREMOVE))
|
|
|
|
{
|
2001-11-04 10:31:58 +08:00
|
|
|
me->read_ready = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
select_printf ("window %d(%p) ready", me->fd, me->fh->get_handle ());
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_printf ("window %d(%p) not ready", me->fd, me->fh->get_handle ());
|
|
|
|
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 *
|
|
|
|
fhandler_windows::select_read (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
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;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_windows::select_write (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_windows;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->write_selected = true;
|
|
|
|
s->write_ready = true;
|
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
select_record *
|
|
|
|
fhandler_windows::select_except (select_record *s)
|
|
|
|
{
|
|
|
|
if (!s)
|
|
|
|
{
|
|
|
|
s = new select_record;
|
|
|
|
s->startup = no_startup;
|
|
|
|
s->verify = verify_ok;
|
|
|
|
}
|
2001-11-04 10:31:58 +08:00
|
|
|
s->peek = peek_windows;
|
2000-02-18 03:38:33 +08:00
|
|
|
s->h = get_handle ();
|
2001-11-04 10:31:58 +08:00
|
|
|
s->except_selected = true;
|
|
|
|
s->except_ready = true;
|
|
|
|
s->windows_handle = true;
|
2000-02-18 03:38:33 +08:00
|
|
|
return s;
|
|
|
|
}
|