From 967521bd32ab073e4d594b3cd98dba3a8d88626a Mon Sep 17 00:00:00 2001 From: Scott Lindeneau Date: Thu, 4 Sep 2008 04:45:55 +0900 Subject: [PATCH] Modifies accept_socket, allows it to take sock structures instead of handlers. To: wine-patches This patch splits the accept_socket call into two parts, one part that gets the struct sock* objects and one part that manages the actual accept. This is used later when the wineserver is processing acceptex calls and the global variable current is NULL. (We can't grab the objects then). --- server/sock.c | 54 +++++++++++++++++++++++++++++++++--------------------- 1 files changed, 33 insertions(+), 21 deletions(-) diff --git a/server/sock.c b/server/sock.c index 1c0034e..26387b1 100644 --- a/server/sock.c +++ b/server/sock.c @@ -620,18 +620,12 @@ static struct object *create_socket( int family, int type, int protocol, unsigne return &sock->obj; } -/* accept a socket (creates a new fd) */ -static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) +/* accept a socket (creates a new fd) (takes objects instead of handles) */ +static struct sock *accept_socket_obj( struct sock *sock, struct sock *acceptsock ) { - struct sock *acceptsock = NULL; - struct sock *sock; int acceptfd; struct sockaddr saddr; - sock = (struct sock *)get_handle_obj( current->process, handle, FILE_READ_DATA, &sock_ops ); - if (!sock) - return NULL; - if ( sock->deferred ) { acceptsock = sock->deferred; @@ -649,24 +643,16 @@ static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) if (acceptfd==-1) { sock_set_error(); - release_object( sock ); return NULL; } - - if(ahandle){ - acceptsock = (struct sock *)get_handle_obj(current->process, ahandle, FILE_READ_DATA | FILE_WRITE_DATA, &sock_ops ); - if(acceptsock){ - if(acceptsock->event) - release_object( acceptsock->event ); - release_object( acceptsock->fd ); - } - }else{ + + if(!acceptsock) + { acceptsock = alloc_object( &sock_ops ); } if (!acceptsock) { close( acceptfd ); - release_object( sock ); return NULL; } @@ -684,7 +670,6 @@ static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) acceptsock->event = NULL; acceptsock->window = sock->window; acceptsock->message = sock->message; - acceptsock->wparam = ahandle; if (sock->event) acceptsock->event = (struct event *)grab_object( sock->event ); acceptsock->flags = sock->flags; acceptsock->deferred = NULL; @@ -694,7 +679,6 @@ static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) get_fd_options( sock->fd ) ))) { release_object( acceptsock ); - release_object( sock ); return NULL; } } @@ -705,6 +689,34 @@ static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) release_object( sock ); return acceptsock; } +/* accept a socket (creates a new fd) */ +static struct sock *accept_socket( obj_handle_t handle, obj_handle_t ahandle ) +{ + struct sock *acceptsock = NULL; + struct sock *sock,*ret; + + sock = (struct sock *)get_handle_obj( current->process, handle, FILE_READ_DATA, &sock_ops ); + if (!sock) + return NULL; + if(ahandle) + { + acceptsock = (struct sock *)get_handle_obj(current->process, ahandle, FILE_READ_DATA | FILE_WRITE_DATA, &sock_ops ); + if(acceptsock){ + if(acceptsock->event) + release_object( acceptsock->event ); + release_object( acceptsock->fd ); + } + } + ret = accept_socket_obj( sock, acceptsock ); + if( ret != NULL) + { + ret->wparam = ahandle; + } + if( acceptsock ) + release_object( acceptsock ); + release_object( sock ); + return ret; +} /* set the last error depending on errno */ static int sock_get_error( int err ) -- 1.5.4.3