1
0
mirror of https://github.com/wine-mirror/wine synced 2024-07-05 17:28:47 +00:00
Commit Graph

339 Commits

Author SHA1 Message Date
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
Zebediah Figura
869cbc4b4b server: Set the connection time if connect() returns 0. 2022-07-15 11:31:51 +02:00
Zebediah Figura
ea6f88d83f server: Do not set the socket state in complete_async_connect().
It's already set previously in sock_poll_event(). Moreover, complete_async_connect() will not always be called.
2022-07-15 11:31:50 +02:00
Zebediah Figura
647bed72f5 server: Remove the unused "flags" field from struct sock. 2022-07-15 11:31:48 +02:00
Zebediah Figura
41d16358dc server: Remove the no longer used sock_queue_async() function. 2022-07-14 10:29:14 +02:00
Paul Gofman
07d3c82395 server: Allow IOCTL_AFD_POLL for sockets without unix fd.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
2022-07-05 10:00:18 +02:00
David Curtiss
68d4643a67 ws2_32: Allow getsockname after AcceptEx.
.NET 6's HTTP/Socket code queries this. Winsock allows getsockname
on the AcceptEx AcceptSocket, but only if SO_UPDATE_ACCEPT_CONTEXT
is set.

Signed-off-by: David Curtiss <david.curtiss@ni.com>
2022-06-20 23:26:50 +02:00
Piotr Caban
0c7928061c server: Don't reset socket error in IOCTL_AFD_GET_SO_ERROR.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
2022-06-13 21:33:54 +02:00
Piotr Caban
73648f901c server: Don't reset socket error in poll_socket.
Otherwise socket error may be cleared in poll_socket causing ioctl SO_ERROR calls to return no error.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51433
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
2022-06-13 21:33:54 +02:00
Piotr Caban
9d1085c8d3 server: Always return Win32 error code from IOCTL_AFD_GET_SO_ERROR.
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
2022-06-13 21:33:54 +02:00
Zebediah Figura
5a4e39795f server: Remove a redundant call to set_fd_events().
We will always call set_fd_events() again in sock_reselect().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-06 12:06:41 +02:00
Zebediah Figura
753fbb28d5 server: Do not signal accept bits if there are accept asyncs queued.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:36:28 +02:00
Zebediah Figura
bff228c198 server: Do not signal write bits if there are write asyncs alerted.
Asyncs which are alerted but not "waiting" may still fill the pipe, and we
shouldn't signal AFD_POLL_WRITE in that case.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:36:22 +02:00
Zebediah Figura
c5541f8a08 server: Don't poll for POLLOUT if there are alerted write asyncs.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:36:15 +02:00
Zebediah Figura
30a56639fd server: Do not signal read bits if there are read asyncs alerted.
Asyncs which are alerted but not "waiting" may still consume all data, and we
shouldn't signal AFD_POLL_READ or AFD_POLL_OOB in that case.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:36:09 +02:00
Zebediah Figura
04b33ef098 server: Don't poll for POLLIN or POLLPRI if there are alerted read asyncs.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:36:03 +02:00
Zebediah Figura
cafd260014 server: Do not signal read/write bits if there are read/write asyncs waiting.
This is validated by tests introduced in
59beffb46c etc. This commit alone doesn't fix said
tests, because:

* on this poll, we will alert the waiting async;

* when reselecting, we will still request POLLIN, because the AFD_POLL_READ
  request is still active,

* when POLLIN is subsequently signaled, we do not remove it in
  sock_dispatch_asyncs(), because we check async_waiting(), not async_queued().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-05 18:35:56 +02:00
Zebediah Figura
683d46a2cd server: Clear only returned events in IOCTL_AFD_GET_EVENTS.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 21:59:22 +02:00
Zebediah Figura
ad078be430 server: Send AFD_POLL_READ messages before AFD_POLL_WRITE.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-05-04 21:51:23 +02:00
Zebediah Figura
677eee8e7d server: Return void from sock_reselect().
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-04-27 11:54:08 +02:00
Jinoh Kang
731a968003 server: Replace redundant send_socket status fields with force_async boolean field.
The 'status' field of send_socket_request is always either
STATUS_PENDING or STATUS_DEVICE_NOT_READY, and the 'total' field is
always zero.

Replace the 'status' field with 'force_async' boolean field, and get rid
of the 'total' field entirely.

Also, clean up the send_socket handler code a bit.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-25 18:30:28 +01:00
Jinoh Kang
0ac256eacc server: Ensure datagram sockets are bound in send_socket.
If the type of the socket is SOCK_DGRAM, it shall always be bound to an
address if we ever attempt to send datagrams through the socket, whether
the attempt succeeds or not.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-25 18:30:28 +01:00
Jinoh Kang
65d12984f2 server: Attempt to complete I/O request immediately in send_socket.
Make send_socket alert the async immediately if poll() call detects that
there are incoming data in the socket, bypassing the wineserver's main
polling loop.

For sock_transmit, we always mark the async as pending and set the IOSB
(unless async allocation has failed).

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-25 18:30:28 +01:00
Jinoh Kang
1c6c90c7e1 server: Defer clearing events until async is completed in send_socket handler.
This allows the initial I/O to be performed after the send_socket
handler is called.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-03-25 18:28:37 +01:00
Jinoh Kang
dea1499ac0 server: Replace redundant recv_socket status fields with force_async boolean field.
The 'status' field of recv_socket_request is always either
STATUS_PENDING or STATUS_DEVICE_NOT_READY, and the 'total' field is
always zero.

Replace the 'status' field with 'force_async' boolean field, and get rid
of the 'total' field entirely.

Also, clean up the recv_socket handler code a bit.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-10 20:18:39 +01:00
Jinoh Kang
e5ce4fa917 server: Attempt to complete I/O request immediately in recv_socket.
Make recv_socket alert the async immediately if poll() call detects that
there are incoming data in the socket, bypassing the wineserver's main
polling loop.

Signed-off-by: Jinoh Kang <jinoh.kang.kr@gmail.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-10 20:18:39 +01:00
Paul Gofman
4c1a288f63 server: Always update cached socket name after connect.
Fixes a regression introduced by
5c009c17b3.

For IPV6 socket already bound with bind() with IPV6_V6ONLY set to 0
the address returned by getsockname() may change after it is connected
to a IPV4 peer (e. g., from :: to ::ffff:192.0.2.128).

The effect of blamed commit is that before that Unix getsockname()
was called for each ws2_32 getsockname() and after the commit the
socket name is cached at bind and connect.

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-02-08 15:26:16 +01:00
Paul Gofman
0839773db2 server: Release correct sockets in poll_socket().
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-25 20:50:47 +01:00
Zebediah Figura
51e5995d47 server: Avoid reporting POLLOUT on connection failure in poll_single_socket().
Ideally we should be using sock_get_poll_events() and sock_poll_event() instead,
but that seems like an overly risky change for this late in code freeze.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51442
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-07 11:57:00 +01:00
Zebediah Figura
9632048c68 server: Set the event in IOCTL_AFD_EVENT_SELECT if the socket becomes signaled.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52335
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2022-01-06 11:34:47 +01:00
Zebediah Figura
b1a2238a10 server: Reselect the socket returned from accept_socket().
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52024
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-30 23:09:45 +01:00
Zebediah Figura
4b00dd097d server: Handle the entire IOCTL_AFD_POLL ioctl on the server side.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Zebediah Figura
06fdbd6eda server: Rename the "flags" field of struct poll_req to "mask".
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-10 22:00:17 +01:00
Alexandre Julliard
e5d69d9ee6 configure: Assume that sys/ioctl.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Alexandre Julliard
a7ac3de3b3 configure: Assume that sys/socket.h is available on Unix.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-12-09 18:43:51 +01:00
Huw Davies
6fdae1979b configure: Stop checking for poll.h and sys/poll.h - always use poll.h.
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-31 17:56:54 +01:00
Paul Gofman
5f916f7f35 server: Use SO_BINDTODEVICE in bind_to_index() if possible.
Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-18 17:04:01 +02:00
Zebediah Figura
e6009c5b55 server: Avoid touching the poll_req structure after calling async_request_complete() (Valgrind).
Fixes: 567beb6b2e
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-13 13:05:23 +02:00
Zebediah Figura
567beb6b2e server: Avoid leaking the poll output buffer if the request is terminated irregularly (Valgrind).
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 11:27:57 +02:00
Zebediah Figura
60dd202fbd server: Do not allocate a connect_req structure for nonblocking sockets (Valgrind).
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-10-08 11:27:52 +02:00
Guillaume Charifi
5990f19bdc ntdll: Implement exclusive flag for IOCTL_AFD_POLL.
Signed-off-by: Guillaume Charifi <guillaume.charifi@sfr.fr>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-23 10:28:16 +02:00
Zebediah Figura
c3b32dbccf server: Factor out a complete_async_poll() helper.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-23 10:27:33 +02:00
Zebediah Figura
a1c42293a2 server: Don't wake up always-blocking asyncs.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-09 22:30:45 +02:00
Zebediah Figura
4f1c7ba5f9 server: Cancel asyncs through fd_ops.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-09 22:30:45 +02:00
Zebediah Figura
08eaf8f481 server: Make sure that async_request_complete() is called in the case of a failed connection as well.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51726
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
2021-09-07 10:16:27 +02:00