1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-01 07:14:31 +00:00
Commit Graph

383 Commits

Author SHA1 Message Date
Paul Gofman
4d56a33ab0 server: Ignore some ICMP-originated socket errors for connectionless sockets. 2024-03-15 23:48:52 +01:00
Paul Gofman
da6e707850 server: Check if we have waiting asyncs in sock_dispatch_asyncs() before clearing POLLOUT. 2024-02-02 13:02:04 +01:00
Paul Gofman
aac0998262 server: Check if we have waiting asyncs in (send_socket) before enforcing blocking send. 2024-02-02 13:01:55 +01:00
Gabriel Brand
6361a20c52 server: Return failure in bind if the address is not found. 2024-01-25 21:00:06 +01:00
Fabian Maurer
13928e0855 server: Check socket flags after all sockets got processed.
In rare cases we get an event during the second iteration of the loop,
changing the first element. This would lead to an assertion later.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55054
2023-12-01 18:51:49 +01:00
Zebediah Figura
2f0153df7c server: Translate AFD_POLL_RESET to FD_CLOSE plus WSAECONNABORTED in window messages. 2023-11-22 20:03:04 +01:00
Zebediah Figura
a866d16ff8 server: Return ERROR_CONNECTION_RESET when trying to recv() on a reset socket. 2023-11-22 20:03:04 +01:00
Zebediah Figura
25f8698fcd server: Only set sock->event when the event is first noticed.
Do not set it every time another event is polled.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55838
2023-10-31 18:52:07 +01:00
Ally Sommers
3582ba9dc4 server: Move getpeername() implementation from ntdll/unix.
This brings getpeername() in line with getsockname(), which
is also implemented in wineserver. It also allows getpeername()
to return a possibly-more-accurate peer name, as in the case of
AF_UNIX sockets.
2023-10-05 10:03:23 +02:00
Paul Gofman
2c2740629b server: Hold socket reference in sock_poll_event(). 2023-10-05 09:59:24 +02:00
Ally Sommers
998febf7cf server: Return WSAEOPNOTSUPP on listen() if the socket's type is SOCK_DGRAM. 2023-09-18 20:35:58 +02:00
Paul Gofman
578fc9c96f server: Don't set SO_RCVBUF below Windows default value on Unix socket. 2023-09-12 20:34:14 +02:00
Zebediah Figura
dbe7788817 server: Signal AFD_POLL_BIT_WRITE at the same time as AFD_POLL_BIT_CONNECT.
Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=55333
2023-08-28 11:22:22 +02:00
Torge Matthies
91f8926023 server: Don't consider non-pending poll requests when reselecting socket.
Signed-off-by: Torge Matthies <openglfreak@googlemail.com>
2023-08-14 13:32:26 +02:00
Jinoh Kang
915c391014 server: Avoid relying on linux/ipx.h to define SOL_IPX.
musl libc doesn't supply any definitions for IPX, such as the SOL_IPX
macro.  However, it still provides linux/ipx.h from Linux uAPI header
files if it exists.

Linux kernel wouldn't drop linux/ipx.h from uAPI headers until 5.15,
although IPX support has already been marked obsolete since 2018.

Fix this by not defining HAS_IPX if linux/ipx.h has been included but
nothing defines the SOL_IPX macro.

Status of IPX support from other libcs are noted below:

- bionic: netipx/ipx.h does not exist.  linux/ipx.h may or may not
  exist.  Note that sys/socket.h defines SOL_IPX even if linux/ipx.h is
  missing.

- glibc: netipx/ipx.h exists.  In this case, Wine assumes IPX support
  even if the operating system does not support it in runtime.

- BSD variants: netipx/ipx.h may or may not exist.  linux/ipx.h does not
  exist.  Some BSDs supply SO_DEFAULT_HEADERS instead of SOL_IPX.

Fixes: 41cc117b3f
2023-08-05 10:45:10 +09:00
Zebediah Figura
01afb21bf2 ws2_32: Move the event reset in WSAEnumNetworkEvents() to the server.
So that it is done atomically with retrieving events.

Wine-Bug: https://bugs.winehq.org//show_bug.cgi?id=52474
2023-07-24 22:51:06 +02:00
Zebediah Figura
0a33ac4a53 server: Move the implementation of IOCTL_AFD_GET_EVENTS to a dedicated server call. 2023-07-24 22:51:00 +02:00
Paul Gofman
57095a91b0 server: Cancel socket asyncs when the last handle in process is closed. 2023-07-20 21:48:39 +02:00
Billy Laws
41cc117b3f server: Avoid using SOL_IPX to detect whether IPX is supported. 2023-07-04 20:55:34 +02:00
Paul Gofman
74240a3545 server: Set TCP SYN count on sockets. 2023-02-21 11:21:27 +01:00
Paul Gofman
4e6a5d62ad server: Retry socket connection on ECONNABORTED error. 2023-02-21 11:21:05 +01:00
Zebediah Figura
03391aab24 server: Inherit the SO_RCVTIMEO value in accept_socket(). 2022-12-13 12:47:21 +01:00
Zebediah Figura
418dff0c01 server: Inherit the SO_SNDTIMEO value in accept_socket(). 2022-12-13 12:47:21 +01:00
Zebediah Figura
1ef2cc0f64 server: Inherit the SO_RCVBUF value in accept_socket().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53911
2022-12-13 12:47:21 +01:00
Zebediah Figura
a58cd78ca9 server: Inherit the SO_SNDBUF value in accept_socket(). 2022-12-13 12:47:21 +01:00
Zebediah Figura
ddc6c3fb23 server: Inherit address reuse flags in accept_socket(). 2022-12-13 12:47:21 +01:00
Paul Gofman
a9ae1e041c server: Support SO_EXCLUSIVEADDRUSE socket option. 2022-11-04 19:23:55 +01:00
Paul Gofman
003ee6202b server: Do not translate loopback addr in ipv4addr_from_v6(). 2022-11-04 19:23:55 +01:00
Paul Gofman
0328ba93f3 server: Use htonl() with INADDR_ANY in ipv4addr_from_v6(). 2022-11-04 19:23:55 +01:00
Paul Gofman
6992f2cba5 server: Set error in check_addr_usage(). 2022-11-04 19:23:55 +01:00
Paul Gofman
9163d3420f server: Use struct bound_addr as a key to bound_addresses_tree. 2022-11-04 19:23:54 +01:00
Paul Gofman
12b604926e server: Make SO_REUSEADDR and SO_EXCLUSIVEADDRUSE mutually exclusive. 2022-11-04 19:23:54 +01:00
Paul Gofman
d656cb2024 ws2_32: Track SO_EXCLUSIVEADDRUSE option value. 2022-11-04 19:23:54 +01:00
Paul Gofman
ef7de1fc1f server: Set Unix SO_REUSEADDR on all the TCP sockets.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50955
2022-10-31 20:41:45 +01:00
Paul Gofman
382ec78db3 server: Track SO_REUSEADDR value. 2022-10-31 20:41:45 +01:00
Paul Gofman
039f8b16f6 ntdll: Move SO_REUSEADDR handling to server. 2022-10-31 20:41:45 +01:00
Jinoh Kang
a115feab9c server: Always prefer synchronous I/O in nonblocking mode.
foobar2000.exe's UPnP Media Renderer component (foo_out_upnp.dll)
expects that, if a select() call completes successfully with a non-empty
writefds set, any immediately following send() call on a socket in the
writefds set never fails with WSAEWOULDBLOCK.

On Wine, the Winsock select() and send() implementations both call the
Unix poll(2) under the hood to test if I/O is possible on the socket.
As it turns out, it's entirely possible that Linux poll() may yield
POLLOUT on the first call (by select) but *not* the second (by send),
even if no send() call has been made in the meanwhile.

On Linux (as of v5.19), a connected (ESTABLISHED) TCP socket that has
not been shut down indicates (E)POLLOUT only if the ratio of
sk_wmem_queued (the amount of bytes queued in the send buffer) to
sk_sndbuf (the size of send buffer size itself, which can be retrieved
via SO_SNDBUF) is below a certain threshold.  Therefore, a falling edge
in POLLOUT can be triggered due to a number of reasons:

1. TCP fragmentation.  Once a TCP packet is split out from a larger
   sk_buff, it incurs extra bookkeeping overhead (e.g. sk_buff header)
   that is counted in sk_wmem_queued alongside application data.
   See also: tcp_fragment(), tso_fragment() (Linux 5.19).

2. Control packets (e.g. MTU probing).  Such packets share the same
   buffer with application-initiated packets, and thus counted in
   sk_wmem_queued.
   See also: sk_wmem_queued_add() callers (Linux 5.19).

3. Memory pressure.  This causes sk_sndbuf to shrink.
   See also: sk_stream_moderate_sndbuf() callers (Linux 5.19).

Fix this by always attempting synchronous I/O first if req->force_async
is unset and the nonblocking flag is set.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53486
2022-08-24 09:06:37 -05:00
Jinoh Kang
13fb500cbb server: Use check_fd_events() instead of calling poll() directly. 2022-08-24 09:06:37 -05:00
Jinoh Kang
78f1dd8967 server: Use POLLIN instead of POLLPRI if the socket is in oobinline mode. 2022-08-24 09:06:37 -05:00
Zebediah Figura
7961e00e74 server: Properly implement AFD_POLL_RESET. 2022-07-25 09:38:21 +02:00
Zebediah Figura
1d0e21db29 server: Move sock->error setting completely out of sock_dispatch_events(). 2022-07-21 20:21:46 +02:00
Zebediah Figura
41cdc6674c server: Report the socket error in sock_poll_event() on POLLERR or POLLHUP.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52815
2022-07-21 20:21:45 +02:00
Zebediah Figura
a2f2b773fb server: Record the error for connected and connectionless sockets sockets in sock_error().
As long as we do it for connecting and listening sockets, do it here for the
remaining socket types as well.
2022-07-21 20:21:44 +02:00
Zebediah Figura
a1fd99cfbb server: Clear sock->errors[AFD_POLL_BIT_CONNECT_ERR] in sock_poll_event().
Give sock_dispatch_events() a more consistent scope.
2022-07-21 20:21:42 +02:00
Zebediah Figura
236476417a server: Use sock_poll_event() in poll_socket().
In multiple cases errors may be reported only once by the host socket
implementation, but should persist for Windows sockets. These cases are
currently not handled by poll_socket().

poll_socket() also does not include logic for filtering out events when asyncs
are queued or alerted on the relevant socket.

Hence, instead of duplicating more logic, remove the logic already duplicated,
and just call sock_poll_event(), so that there is one central place where events
are translated.

Mark the currently active poll async with a special "pending" field so that
poll_socket() does not attempt to complete it before all sockets are checked.
2022-07-20 22:33:44 +02:00
Zebediah Figura
f234341ca1 server: Always wake up pending read or write asyncs on POLLHUP or POLLERR.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52815
2022-07-20 22:33:44 +02:00
Zebediah Figura
07b66768b1 Revert "server: Explicitly shutdown destroyed sockets to force pending poll() calls to return.".
This reverts commit 24b64534e5.

We no longer perform any blocking waits on the client side, so shutdown() is no
longer necessary.

Moreover, shutting down is not always correct. Under some conditions, closing a
TCP socket should trigger RST without FIN (namely, when SO_LINGER is on but has
a zero timeout). By reverting this commit we match Windows behaviour in this
respect.
2022-07-20 22:33:44 +02:00
Zebediah Figura
8a4433d6a7 server: Do not set connectionless sockets into the CONNECTING or CONNECTED state.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53058
2022-07-19 20:02:15 +02:00
Paul Gofman
0f337f3d8e ntdll: Fixup ICMP packet id if SOCK_DGRAM fallback is used.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
2022-07-18 10:39:41 +02:00
Paul Gofman
1e35966eb5 ntdll: Support SOCK_RAW / IPPROTO_ICMP fallback over SOCK_DGRAM.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
2022-07-18 10:39:26 +02:00