b55e3f19 was a bit too aggressive in dropping, rather than just
un-exporting these Makefile variables. We need to set these to the
configured host compiler if we are cross-compiling, otherwise they
default to the build compiler.
Also export CC to the mkvers.sh script (which requires it since
4eca5e6a). It's unclear why we can't just cause windres to use the
build 'cpp' as the pre-processor there.
Add a new HANDLE argument to peek_pipe and peek_pipe_poll so that the
caller can specify a pipe handle to use in lieu of get_handle(). Use
this in recvmsg to make the MSG_PEEK flag work for unbound datagram
sockets.
Untested.
If the caller doesn't specify ancillary data, add credentials to the
outgoing packet.
This enables us to satisfy the requirement
(https://man7.org/linux/man-pages/man7/unix.7.html) that a socket with
the SO_PASSCRED option enabled can get the credentials of its peer in
every message it receives.
FIXME: I'm not sure if this is the right way to satisfy that
requirement. A possible alternative would be to arrange for a socket
to be notified when its peer enables SO_PASSCRED.
Call set_nonblocking before creating the pipe so that the pipe is
created with the correct blocking mode.
Also call set_pipe_non_blocking on the second socket so that the
client end of the pipe has the correct blocking mode. This also makes
sure that the client end of the pipe is set to message mode for
reading.
If the caller has requested the source address, try to get it on each
iteration of the main read loop, not just the first. Set msg_namelen
to 0 if it is never received.
If a packet containing control message data is received, don't read
any more packets, even if MSG_WAITALL is set.
The return value is now -NaN.
This fixes a bug in the mingw-w64 code that was imported into Cygwin.
The fix is consistent with Posix and Linux. It is also consistent
with the current mingw-w64 code, with one exception: The mingw-w64
code sets errno to EDOM if the input is -NaN, but this appears to
differ from Posix and Linux.
Addresses: https://cygwin.com/pipermail/cygwin/2020-October/246606.html
- Calling ResizePseudoConsole() generates some escape sequences.
Due to this behaviour, if the output of non-cygwin app is piped
to less, screen is sometimes distorted when the screen is resized.
With this patch, ResizePseudoConsole() is not called if stdout is
redirected.
- If output of non-cygwin process is piped to cygwin process, such
as less, the non-cygwin process sometimes fails to start and hangs.
This patch fixes the issue.
If there's unread data in the pipe from a previous partial read of a
packet, just return. There can't be an administrative packet waiting
to be read in that case.
Define it to be UINT16_MAX, since the pckt_len member of
af_unix_pkt_hdr_t is of type uint16_t.
Previously it was 65536 (== UINT16_MAX + 1), which is 0 when cast to
uint16_t. So an attempt to write a packet of size MAX_AF_PKT_LEN
actually wrote 0 bytes.
And use it in recvmsg.
I'm not sure this implementation is what was intended when the
evaluate_cmsg_data method was added.
For now, just support an ancillary data block consisting of a single
cmsghdr, containing SCM_CREDENTIALS.
For convenience, add a 'mshdr *' argument and make the 'cloexec'
argument false by default. The 'cloexec' argument is not currently
used, and I want to avoid having to artificially specify a value for
it when recvmsg calls evaluate_cmsg_data.
For now, just support an ancillary data block consisting of a single
cmsghdr, containing SCM_CREDENTIALS.
FIXME: We're supposed to check the credentials.
If MSG_WAITALL is set, recv_internal calls WSARecv or WSARecvFrom in a
loop, in an effort to fill all the scatter-gather buffers. The test
for whether all the buffers are full was previously incorrect.
Use sizeof (af_unix_shmem_t) as the view size, as when the shared
memory was created. Previously PAGESIZE was used, causing
NtMapViewOfSection to fail with STATUS_INVALID_VIEW_SIZE.
If the socket is listening, then report it as readable (i.e., accept
would not block) if NtQueryInformationFile reports its state as
anything but FILE_PIPE_LISTENING_STATE. Also report it as readable if
NtQueryInformationFile fails.
Untested.
There are many FIXMEs that need attention.
I haven't thought much about datagram sockets. Some of the code might
only work for stream sockets.
select.cc:set_bits sets the readfds entry on wsock sockets that have a
failed connect. Tweak the code so that it applies to all sockets.
To help with this, add virtual connect_state methods to the
fhandler_socket class. Versions of these methods for
fhandler_socket_wsock and fhandler_socket_unix already exist.
ccwrap massages the compiler's standard include directories to remove
'/usr/include/w32api', with the intent of allowing it to be overriden by
'--with-windows-headers' (See 4c36016b).
I'm not 100% convinced that this is always working as desired, since in
some places w32api includes are done using <w32api/something.h>, which
will find them via the path /usr/include.
If this does turn out to be needed, this could also be implemented by
constructing the appropriate compiler flags once, rather than on every
compiler invocation.
As discussed in GCC bug 97088
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97088), parameters in
prototypes of library functions should use reserved names, or no name
at all.
This patch moves the internal struct __tzrule_struct to its own
internal header sys/_tz_structs.h. This is included from newlib's
time code as well as from Cygwin's localtime wrapper.
Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Call grab_admin_pkt at appropriate times to check whether we've been
shut down for reading. Also, update our shutdown state whenever we
read a packet.
Untested.
FIXME: I'm not sure whether I've treated datagram sockets properly.
Extract from grab_admin_pkg two new methods, record_shut_info and
process_admin_pkg. Also add a new 'peek' argument to grab_admin_pkg.
If this is true, peek to see if the next packet in the pipe is an
administrative packet. Otherwise, assume we already know it is.