* cygthread.cc (cygthread::initialized): Avoid copying on fork or some threads
may not end up in the pool. (cygthread::new): Avoid race when checking for initialized. Add debugging code. * fhandler.cc (fhandler_base::raw_read): Add case for ERROR_INVALID_HANDLE due to Win95 directories. (fhandler_base::open): Handle errors due to Win95 directories. (fhandler_base::close): Add get_nohandle () test. (fhandler_base::set_close_on_exec): Ditto. (fhandler_base::fork_fixup): Ditto. (fhandler_base::lock): Change error code to Posix EINVAL. (fhandler_base::dup): If get_nohandle (), set new value to INVALID_HANDLE_VALUE instead of NULL. * fhandler_disk_file.cc (fhandler_disk_file::fstat): Call fstat_by_name if get_nohandle (). Remove extraneous element from strpbrk. (fhandler_disk_file::open): Remove test for Win95 directory. * fhandler_random.cc (fhandler_dev_random::open): Add set_nohandle (). * fhandler_clipboard.cc (fhandler_dev_clipboard::open): Ditto. * fhandler_zero.cc (fhandler_dev_zero::open): Ditto. (fhandler_dev_zero::close): Delete. * fhandler.h (class fhandler_dev_zero): Ditto.
This commit is contained in:
@@ -325,7 +325,7 @@ fhandler_socket::bind (const struct sockaddr *name, int namelen)
|
||||
{
|
||||
#define un_addr ((struct sockaddr_un *) name)
|
||||
struct sockaddr_in sin;
|
||||
int len = sizeof sin;
|
||||
int len = sizeof sin;
|
||||
int fd;
|
||||
|
||||
if (strlen (un_addr->sun_path) >= UNIX_PATH_LEN)
|
||||
@@ -513,45 +513,45 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
|
||||
int wait_result;
|
||||
|
||||
wait_result = WSAWaitForMultipleEvents (2, ev, FALSE, WSA_INFINITE,
|
||||
FALSE);
|
||||
if (wait_result == WSA_WAIT_EVENT_0)
|
||||
WSAEnumNetworkEvents (get_socket (), ev[0], &sock_event);
|
||||
FALSE);
|
||||
if (wait_result == WSA_WAIT_EVENT_0)
|
||||
WSAEnumNetworkEvents (get_socket (), ev[0], &sock_event);
|
||||
|
||||
/* Unset events for listening socket and
|
||||
switch back to blocking mode */
|
||||
WSAEventSelect (get_socket (), ev[0], 0);
|
||||
/* Unset events for listening socket and
|
||||
switch back to blocking mode */
|
||||
WSAEventSelect (get_socket (), ev[0], 0);
|
||||
unsigned long nonblocking = 0;
|
||||
ioctlsocket (get_socket (), FIONBIO, &nonblocking);
|
||||
ioctlsocket (get_socket (), FIONBIO, &nonblocking);
|
||||
|
||||
switch (wait_result)
|
||||
{
|
||||
case WSA_WAIT_EVENT_0:
|
||||
if (sock_event.lNetworkEvents & FD_ACCEPT)
|
||||
{
|
||||
if (sock_event.iErrorCode[FD_ACCEPT_BIT])
|
||||
{
|
||||
WSASetLastError (sock_event.iErrorCode[FD_ACCEPT_BIT]);
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/* else; : Should never happen since FD_ACCEPT is the only event
|
||||
that has been selected */
|
||||
break;
|
||||
case WSA_WAIT_EVENT_0 + 1:
|
||||
debug_printf ("signal received during accept");
|
||||
set_errno (EINTR);
|
||||
res = -1;
|
||||
goto done;
|
||||
case WSA_WAIT_FAILED:
|
||||
default: /* Should never happen */
|
||||
WSASetLastError (WSAEFAULT);
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
switch (wait_result)
|
||||
{
|
||||
case WSA_WAIT_EVENT_0:
|
||||
if (sock_event.lNetworkEvents & FD_ACCEPT)
|
||||
{
|
||||
if (sock_event.iErrorCode[FD_ACCEPT_BIT])
|
||||
{
|
||||
WSASetLastError (sock_event.iErrorCode[FD_ACCEPT_BIT]);
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
/* else; : Should never happen since FD_ACCEPT is the only event
|
||||
that has been selected */
|
||||
break;
|
||||
case WSA_WAIT_EVENT_0 + 1:
|
||||
debug_printf ("signal received during accept");
|
||||
set_errno (EINTR);
|
||||
res = -1;
|
||||
goto done;
|
||||
case WSA_WAIT_FAILED:
|
||||
default: /* Should never happen */
|
||||
WSASetLastError (WSAEFAULT);
|
||||
set_winsock_errno ();
|
||||
res = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = ::accept (get_socket (), peer, len);
|
||||
@@ -566,7 +566,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
|
||||
{
|
||||
if (!create_secret_event ())
|
||||
secret_check_failed = TRUE;
|
||||
else if (in_progress)
|
||||
else if (in_progress)
|
||||
signal_secret_event ();
|
||||
}
|
||||
|
||||
@@ -599,12 +599,12 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
|
||||
set_winsock_errno ();
|
||||
else
|
||||
{
|
||||
fhandler_socket* res_fh = fdsock (res_fd, get_name (), res);
|
||||
if (get_addr_family () == AF_LOCAL)
|
||||
res_fh->set_sun_path (get_sun_path ());
|
||||
res_fh->set_addr_family (get_addr_family ());
|
||||
res_fh->set_socket_type (get_socket_type ());
|
||||
res = res_fd;
|
||||
fhandler_socket* res_fh = fdsock (res_fd, get_name (), res);
|
||||
if (get_addr_family () == AF_LOCAL)
|
||||
res_fh->set_sun_path (get_sun_path ());
|
||||
res_fh->set_addr_family (get_addr_family ());
|
||||
res_fh->set_socket_type (get_socket_type ());
|
||||
res = res_fd;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ fhandler_socket::recvmsg (struct msghdr *msg, int flags, ssize_t tot)
|
||||
{
|
||||
tot = 0;
|
||||
const struct iovec *iovptr = iov + iovcnt;
|
||||
do
|
||||
do
|
||||
{
|
||||
iovptr -= 1;
|
||||
tot += iovptr->iov_len;
|
||||
@@ -903,7 +903,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
|
||||
{
|
||||
set_errno (EPIPE);
|
||||
if (! (flags & MSG_NOSIGNAL))
|
||||
_raise (SIGPIPE);
|
||||
_raise (SIGPIPE);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -938,7 +938,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot)
|
||||
{
|
||||
tot = 0;
|
||||
const struct iovec *iovptr = iov + iovcnt;
|
||||
do
|
||||
do
|
||||
{
|
||||
iovptr -= 1;
|
||||
tot += iovptr->iov_len;
|
||||
|
Reference in New Issue
Block a user