mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-14 12:11:48 +00:00
server: Return a WSA error code in accept_socket.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
49babc0bad
commit
70073ff2d0
|
@ -2521,7 +2521,7 @@ static NTSTATUS WS2_async_accept( void *user, IO_STATUS_BLOCK *iosb, NTSTATUS st
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
|
|
||||||
if (status == STATUS_CANT_WAIT)
|
if (NtStatusToWSAError( status ) == WSAEWOULDBLOCK)
|
||||||
return STATUS_PENDING;
|
return STATUS_PENDING;
|
||||||
|
|
||||||
if (status == STATUS_INVALID_HANDLE)
|
if (status == STATUS_INVALID_HANDLE)
|
||||||
|
@ -2760,9 +2760,9 @@ static int WS2_register_async_shutdown( SOCKET s, int type )
|
||||||
*/
|
*/
|
||||||
SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr, int *addrlen32)
|
SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr, int *addrlen32)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
|
||||||
DWORD err;
|
DWORD err;
|
||||||
SOCKET as;
|
SOCKET as;
|
||||||
|
int fd;
|
||||||
BOOL is_blocking;
|
BOOL is_blocking;
|
||||||
|
|
||||||
TRACE("socket %04lx\n", s );
|
TRACE("socket %04lx\n", s );
|
||||||
|
@ -2770,18 +2770,19 @@ SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr, int *addrlen32)
|
||||||
if (err)
|
if (err)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
do {
|
for (;;)
|
||||||
|
{
|
||||||
/* try accepting first (if there is a deferred connection) */
|
/* try accepting first (if there is a deferred connection) */
|
||||||
SERVER_START_REQ( accept_socket )
|
SERVER_START_REQ( accept_socket )
|
||||||
{
|
{
|
||||||
req->lhandle = wine_server_obj_handle( SOCKET2HANDLE(s) );
|
req->lhandle = wine_server_obj_handle( SOCKET2HANDLE(s) );
|
||||||
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
|
req->access = GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE;
|
||||||
req->attributes = OBJ_INHERIT;
|
req->attributes = OBJ_INHERIT;
|
||||||
status = wine_server_call( req );
|
err = NtStatusToWSAError( wine_server_call( req ));
|
||||||
as = HANDLE2SOCKET( wine_server_ptr_handle( reply->handle ));
|
as = HANDLE2SOCKET( wine_server_ptr_handle( reply->handle ));
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
if (!status)
|
if (!err)
|
||||||
{
|
{
|
||||||
if (addr && addrlen32 && WS_getpeername(as, addr, addrlen32))
|
if (addr && addrlen32 && WS_getpeername(as, addr, addrlen32))
|
||||||
{
|
{
|
||||||
|
@ -2791,16 +2792,14 @@ SOCKET WINAPI WS_accept(SOCKET s, struct WS_sockaddr *addr, int *addrlen32)
|
||||||
TRACE("\taccepted %04lx\n", as);
|
TRACE("\taccepted %04lx\n", as);
|
||||||
return as;
|
return as;
|
||||||
}
|
}
|
||||||
if (is_blocking && status == STATUS_CANT_WAIT)
|
if (!is_blocking) break;
|
||||||
{
|
if (err != WSAEWOULDBLOCK) break;
|
||||||
int fd = get_sock_fd( s, FILE_READ_DATA, NULL );
|
fd = get_sock_fd( s, FILE_READ_DATA, NULL );
|
||||||
/* block here */
|
/* block here */
|
||||||
do_block(fd, POLLIN, -1);
|
do_block(fd, POLLIN, -1);
|
||||||
_sync_sock_state(s); /* let wineserver notice connection */
|
_sync_sock_state(s); /* let wineserver notice connection */
|
||||||
release_sock_fd( s, fd );
|
release_sock_fd( s, fd );
|
||||||
}
|
}
|
||||||
} while (is_blocking && status == STATUS_CANT_WAIT);
|
|
||||||
err = NtStatusToWSAError( status );
|
|
||||||
|
|
||||||
error:
|
error:
|
||||||
WARN(" -> ERROR %d\n", err);
|
WARN(" -> ERROR %d\n", err);
|
||||||
|
|
|
@ -135,7 +135,6 @@ static void sock_reselect_async( struct fd *fd, struct async_queue *queue );
|
||||||
|
|
||||||
static int sock_get_ntstatus( int err );
|
static int sock_get_ntstatus( int err );
|
||||||
static unsigned int sock_get_error( int err );
|
static unsigned int sock_get_error( int err );
|
||||||
static void sock_set_error(void);
|
|
||||||
|
|
||||||
static const struct object_ops sock_ops =
|
static const struct object_ops sock_ops =
|
||||||
{
|
{
|
||||||
|
@ -699,17 +698,13 @@ static int accept_new_fd( struct sock *sock )
|
||||||
* or that accept() is allowed on it. In those cases we will get -1/errno
|
* or that accept() is allowed on it. In those cases we will get -1/errno
|
||||||
* return.
|
* return.
|
||||||
*/
|
*/
|
||||||
int acceptfd;
|
|
||||||
struct sockaddr saddr;
|
struct sockaddr saddr;
|
||||||
socklen_t slen = sizeof(saddr);
|
socklen_t slen = sizeof(saddr);
|
||||||
acceptfd = accept( get_unix_fd(sock->fd), &saddr, &slen);
|
int acceptfd = accept( get_unix_fd(sock->fd), &saddr, &slen );
|
||||||
if (acceptfd == -1)
|
if (acceptfd != -1)
|
||||||
{
|
fcntl( acceptfd, F_SETFL, O_NONBLOCK );
|
||||||
sock_set_error();
|
else
|
||||||
return acceptfd;
|
set_win32_error( sock_get_error( errno ));
|
||||||
}
|
|
||||||
|
|
||||||
fcntl(acceptfd, F_SETFL, O_NONBLOCK); /* make socket nonblocking */
|
|
||||||
return acceptfd;
|
return acceptfd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -936,12 +931,6 @@ static int sock_get_ntstatus( int err )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the last error depending on errno */
|
|
||||||
static void sock_set_error(void)
|
|
||||||
{
|
|
||||||
set_error( sock_get_ntstatus( errno ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_RTNETLINK_H
|
#ifdef HAVE_LINUX_RTNETLINK_H
|
||||||
|
|
||||||
/* only keep one ifchange object around, all sockets waiting for wakeups will look to it */
|
/* only keep one ifchange object around, all sockets waiting for wakeups will look to it */
|
||||||
|
|
Loading…
Reference in a new issue