From aa47705809f60a9811a95c4f7a1f1b6fcb288c31 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Wed, 9 Jan 2002 21:16:24 +0000 Subject: [PATCH] Added support for socket flags. --- include/wine/server_protocol.h | 3 ++- server/protocol.def | 1 + server/sock.c | 31 +++++++++++++++++++++++++++++-- server/trace.c | 3 ++- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 03c06b5853d..af9fa98bfc4 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -874,6 +874,7 @@ struct create_socket_request int family; int type; int protocol; + unsigned int flags; }; struct create_socket_reply { @@ -3042,6 +3043,6 @@ union generic_reply struct get_window_properties_reply get_window_properties_reply; }; -#define SERVER_PROTOCOL_VERSION 69 +#define SERVER_PROTOCOL_VERSION 70 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/protocol.def b/server/protocol.def index 6ab1f35ee3e..7036de158ec 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -640,6 +640,7 @@ enum fd_type int family; /* family, see socket manpage */ int type; /* type, see socket manpage */ int protocol; /* protocol, see socket manpage */ + unsigned int flags; /* socket flags */ @REPLY handle_t handle; /* handle to the new socket */ @END diff --git a/server/sock.c b/server/sock.c index bc901f6cbed..69a129bb3c9 100644 --- a/server/sock.c +++ b/server/sock.c @@ -36,6 +36,7 @@ #include "handle.h" #include "thread.h" #include "request.h" +#include "async.h" /* To avoid conflicts with the Unix socket headers. Plus we only need a few * macros anyway. @@ -50,8 +51,11 @@ struct sock unsigned int mask; /* event mask */ unsigned int hmask; /* held (blocked) events */ unsigned int pmask; /* pending events */ + unsigned int flags; /* socket flags */ struct event *event; /* event object */ int errors[FD_MAX_EVENTS]; /* event errors */ + struct async_queue read_q; /* Queue for asynchronous reads */ + struct async_queue write_q; /* Queue for asynchronous writes */ }; static void sock_dump( struct object *obj, int verbose ); @@ -275,6 +279,9 @@ static int sock_get_fd( struct object *obj ) static int sock_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags ) { + struct sock *sock = (struct sock*) obj; + assert ( obj->ops == &sock_ops ); + if (reply) { reply->type = FILE_TYPE_PIPE; @@ -289,6 +296,7 @@ static int sock_get_info( struct object *obj, struct get_file_info_reply *reply, reply->serial = 0; } *flags = 0; + if (sock->flags & WSA_FLAG_OVERLAPPED) *flags |= FD_FLAG_OVERLAPPED; return FD_TYPE_DEFAULT; } @@ -298,6 +306,13 @@ static void sock_destroy( struct object *obj ) assert( obj->ops == &sock_ops ); /* FIXME: special socket shutdown stuff? */ + + if ( sock->flags & WSA_FLAG_OVERLAPPED ) + { + destroy_async_queue ( &sock->read_q ); + destroy_async_queue ( &sock->write_q ); + } + if (sock->event) { /* if the service thread was waiting for the event object, @@ -311,7 +326,7 @@ static void sock_destroy( struct object *obj ) } /* create a new and unconnected socket */ -static struct object *create_socket( int family, int type, int protocol ) +static struct object *create_socket( int family, int type, int protocol, unsigned int flags ) { struct sock *sock; int sockfd; @@ -330,9 +345,15 @@ static struct object *create_socket( int family, int type, int protocol ) sock->mask = 0; sock->hmask = 0; sock->pmask = 0; + sock->flags = flags; sock->event = NULL; sock_reselect( sock ); clear_error(); + if (sock->flags & WSA_FLAG_OVERLAPPED) + { + init_async_queue (&sock->read_q); + init_async_queue (&sock->write_q); + } return &sock->obj; } @@ -378,6 +399,12 @@ static struct object *accept_socket( handle_t handle ) acceptsock->event = NULL; if (sock->event && !(sock->mask & FD_WINE_SERVEVENT)) acceptsock->event = (struct event *)grab_object( sock->event ); + acceptsock->flags = sock->flags; + if ( acceptsock->flags & WSA_FLAG_OVERLAPPED ) + { + init_async_queue ( &acceptsock->read_q ); + init_async_queue ( &acceptsock->write_q ); + } sock_reselect( acceptsock ); clear_error(); @@ -464,7 +491,7 @@ DECL_HANDLER(create_socket) struct object *obj; reply->handle = 0; - if ((obj = create_socket( req->family, req->type, req->protocol )) != NULL) + if ((obj = create_socket( req->family, req->type, req->protocol, req->flags )) != NULL) { reply->handle = alloc_handle( current->process, obj, req->access, req->inherit ); release_object( obj ); diff --git a/server/trace.c b/server/trace.c index 79ca059823f..c8bb3c50e31 100644 --- a/server/trace.c +++ b/server/trace.c @@ -811,7 +811,8 @@ static void dump_create_socket_request( const struct create_socket_request *req fprintf( stderr, " inherit=%d,", req->inherit ); fprintf( stderr, " family=%d,", req->family ); fprintf( stderr, " type=%d,", req->type ); - fprintf( stderr, " protocol=%d", req->protocol ); + fprintf( stderr, " protocol=%d,", req->protocol ); + fprintf( stderr, " flags=%08x", req->flags ); } static void dump_create_socket_reply( const struct create_socket_reply *req )