[PATCH v3 3/8] server: Defer postprocessing until after setting initial status in recv_socket handler.
Jinoh Kang
jinoh.kang.kr at gmail.com
Mon Feb 21 11:23:16 CST 2022
This allows the client to postpone the initial I/O until after the
server has actually queued the I/O request. The server should perform
the postprocessing only after the initial I/O has been done.
In the case of recv_socket, the manipulation of event flags shall
ideally be done *after* (not *before*) the client has attempted the
initial I/O, since the readiness of the socket may change in the
meanwhile.
Signed-off-by: Jinoh Kang <jinoh.kang.kr at gmail.com>
---
Notes:
v1 -> v2:
- recv_socket_initial_callback: pass OOB flag via private instead of
implementing two separate functions for OOB and non-OOB
v2 -> v3: no changes
server/sock.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/server/sock.c b/server/sock.c
index 91f98556552..f6a65e4e084 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -3393,6 +3393,16 @@ struct object *create_socket_device( struct object *root, const struct unicode_s
return create_named_object( root, &socket_device_ops, name, attr, sd );
}
+static void recv_socket_initial_callback( void *private, struct async *async, struct fd *fd, unsigned int status )
+{
+ struct sock *sock = get_fd_user( fd );
+ int is_oob = (int)(long)private;
+
+ sock->pending_events &= ~(is_oob ? AFD_POLL_OOB : AFD_POLL_READ);
+ sock->reported_events &= ~(is_oob ? AFD_POLL_OOB : AFD_POLL_READ);
+ sock_reselect( sock );
+}
+
DECL_HANDLER(recv_socket)
{
struct sock *sock = (struct sock *)get_handle_obj( current->process, req->async.handle, 0, &sock_ops );
@@ -3430,22 +3440,18 @@ DECL_HANDLER(recv_socket)
if (status == STATUS_PENDING && !req->force_async && sock->nonblocking)
status = STATUS_DEVICE_NOT_READY;
- sock->pending_events &= ~(req->oob ? AFD_POLL_OOB : AFD_POLL_READ);
- sock->reported_events &= ~(req->oob ? AFD_POLL_OOB : AFD_POLL_READ);
-
if ((async = create_request_async( fd, get_fd_comp_flags( fd ), &req->async )))
{
set_error( status );
+ async_set_initial_status_callback( async, recv_socket_initial_callback, (void *)(long)req->oob );
+
if (timeout)
async_set_timeout( async, timeout, STATUS_IO_TIMEOUT );
if (status == STATUS_PENDING || status == STATUS_ALERTED)
queue_async( &sock->read_q, async );
- /* always reselect; we changed reported_events above */
- sock_reselect( sock );
-
reply->wait = async_handoff( async, NULL, 0 );
reply->options = get_fd_options( fd );
reply->nonblocking = sock->nonblocking;
--
2.34.1
More information about the wine-devel
mailing list