Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index a4d89e728b8..25e5294cbf1 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -416,14 +416,6 @@ static void socket_list_remove(SOCKET socket) LeaveCriticalSection(&cs_socket_list); }
-typedef struct /* WSAAsyncSelect() control struct */ -{ - HANDLE service, event, sock; - HWND hWnd; - UINT uMsg; - LONG lEvent; -} ws_select_info; - #define WS_MAX_SOCKETS_PER_PROCESS 128 /* reasonable guess */ #define WS_MAX_UDP_DATAGRAM 1024 static INT WINAPI WSA_DefaultBlockingHook( FARPROC x ); @@ -434,9 +426,6 @@ static FARPROC blocking_hook = (FARPROC)WSA_DefaultBlockingHook; /* function prototypes */ static int ws_protocol_info(SOCKET s, int unicode, WSAPROTOCOL_INFOW *buffer, int *size);
-int WSAIOCTL_GetInterfaceCount(void); -int WSAIOCTL_GetInterfaceName(int intNumber, char *intName); - #define MAP_OPTION(opt) { WS_##opt, opt }
static const int ws_sock_map[][2] =
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 122 ++++++++++++++++++++++--------------------- 1 file changed, 62 insertions(+), 60 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 25e5294cbf1..3c3eef72f51 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4516,78 +4516,80 @@ INT WINAPI WSARecvFrom( SOCKET s, LPWSABUF lpBuffers, DWORD dwBufferCount,
/*********************************************************************** - * WSAAccept (WS2_32.26) + * WSAAccept (ws2_32.@) */ -SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, LPINT addrlen, - LPCONDITIONPROC lpfnCondition, DWORD_PTR dwCallbackData) +SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, int *addrlen, + LPCONDITIONPROC callback, DWORD_PTR context ) { + int ret = 0, size; + WSABUF caller_id, caller_data, callee_id, callee_data; + struct WS_sockaddr src_addr, dst_addr; + GROUP group; + SOCKET cs;
- int ret = 0, size; - WSABUF CallerId, CallerData, CalleeId, CalleeData; - /* QOS SQOS, GQOS; */ - GROUP g; - SOCKET cs; - SOCKADDR src_addr, dst_addr; + TRACE( "socket %#lx, addr %p, addrlen %p, callback %p, context %#lx\n", + s, addr, addrlen, callback, context );
- TRACE("socket %04lx, sockaddr %p, addrlen %p, fnCondition %p, dwCallbackData %ld\n", - s, addr, addrlen, lpfnCondition, dwCallbackData); + cs = WS_accept(s, addr, addrlen); + if (cs == SOCKET_ERROR) return SOCKET_ERROR; + if (!callback) return cs;
- cs = WS_accept(s, addr, addrlen); - if (cs == SOCKET_ERROR) return SOCKET_ERROR; - if (!lpfnCondition) return cs; + if (addr && addrlen) + { + caller_id.buf = (char *)addr; + caller_id.len = *addrlen; + } + else + { + size = sizeof(src_addr); + WS_getpeername( cs, &src_addr, &size ); + caller_id.buf = (char *)&src_addr; + caller_id.len = size; + } + caller_data.buf = NULL; + caller_data.len = 0;
- if (addr && addrlen) - { - CallerId.buf = (char *)addr; - CallerId.len = *addrlen; - } - else - { - size = sizeof(src_addr); - WS_getpeername(cs, &src_addr, &size); - CallerId.buf = (char *)&src_addr; - CallerId.len = size; - } - CallerData.buf = NULL; - CallerData.len = 0; + size = sizeof(dst_addr); + WS_getsockname( cs, &dst_addr, &size );
- size = sizeof(dst_addr); - WS_getsockname(cs, &dst_addr, &size); + callee_id.buf = (char *)&dst_addr; + callee_id.len = sizeof(dst_addr);
- CalleeId.buf = (char *)&dst_addr; - CalleeId.len = sizeof(dst_addr); + ret = (*callback)( &caller_id, &caller_data, NULL, NULL, + &callee_id, &callee_data, &group, context );
- ret = (*lpfnCondition)(&CallerId, &CallerData, NULL, NULL, - &CalleeId, &CalleeData, &g, dwCallbackData); + switch (ret) + { + case CF_ACCEPT: + return cs;
- switch (ret) - { - case CF_ACCEPT: - return cs; - case CF_DEFER: - SERVER_START_REQ( set_socket_deferred ) - { - req->handle = wine_server_obj_handle( SOCKET2HANDLE(s) ); - req->deferred = wine_server_obj_handle( SOCKET2HANDLE(cs) ); - if ( !wine_server_call_err ( req ) ) - { - SetLastError( WSATRY_AGAIN ); - WS_closesocket( cs ); - } - } - SERVER_END_REQ; - return SOCKET_ERROR; - case CF_REJECT: - WS_closesocket(cs); - SetLastError(WSAECONNREFUSED); - return SOCKET_ERROR; - default: - FIXME("Unknown return type from Condition function\n"); - SetLastError(WSAENOTSOCK); - return SOCKET_ERROR; - } + case CF_DEFER: + SERVER_START_REQ( set_socket_deferred ) + { + req->handle = wine_server_obj_handle( SOCKET2HANDLE(s) ); + req->deferred = wine_server_obj_handle( SOCKET2HANDLE(cs) ); + if ( !wine_server_call_err ( req ) ) + { + SetLastError( WSATRY_AGAIN ); + WS_closesocket( cs ); + } + } + SERVER_END_REQ; + return SOCKET_ERROR; + + case CF_REJECT: + WS_closesocket( cs ); + SetLastError( WSAECONNREFUSED ); + return SOCKET_ERROR; + + default: + FIXME( "Unknown return type from Condition function\n" ); + SetLastError( WSAENOTSOCK ); + return SOCKET_ERROR; + } }
+ /*********************************************************************** * WSADuplicateSocketA (WS2_32.32) */
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92717
Your paranoid android.
=== debiant2 (32 bit report) ===
ws2_32: sock.c:4767: Test failed: expected timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- include/wine/afd.h | 1 + server/sock.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/include/wine/afd.h b/include/wine/afd.h index ad8e3abf5ba..6f0a78ca933 100644 --- a/include/wine/afd.h +++ b/include/wine/afd.h @@ -157,6 +157,7 @@ struct afd_get_events_params #define IOCTL_AFD_WINE_KEEPALIVE_VALS CTL_CODE(FILE_DEVICE_NETWORK, 214, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_MESSAGE_SELECT CTL_CODE(FILE_DEVICE_NETWORK, 215, METHOD_BUFFERED, FILE_ANY_ACCESS) #define IOCTL_AFD_WINE_GETPEERNAME CTL_CODE(FILE_DEVICE_NETWORK, 216, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFD_WINE_DEFER CTL_CODE(FILE_DEVICE_NETWORK, 217, METHOD_BUFFERED, FILE_ANY_ACCESS)
struct afd_create_params { diff --git a/server/sock.c b/server/sock.c index bb0d13d9e6c..7b40b6e3f30 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2497,6 +2497,24 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async ) set_reply_data( &sock->addr, sock->addr_len ); return 1;
+ case IOCTL_AFD_WINE_DEFER: + { + const obj_handle_t *handle = get_req_data(); + struct sock *acceptsock; + + if (get_req_data_size() < sizeof(*handle)) + { + set_error( STATUS_BUFFER_TOO_SMALL ); + return 0; + } + + acceptsock = (struct sock *)get_handle_obj( current->process, *handle, 0, &sock_ops ); + if (!acceptsock) return 0; + + sock->deferred = acceptsock; + return 1; + } + default: set_error( STATUS_NOT_SUPPORTED ); return 0;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/ws2_32/socket.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c index 3c3eef72f51..bfc4bb6c09d 100644 --- a/dlls/ws2_32/socket.c +++ b/dlls/ws2_32/socket.c @@ -4564,18 +4564,16 @@ SOCKET WINAPI WSAAccept( SOCKET s, struct WS_sockaddr *addr, int *addrlen, return cs;
case CF_DEFER: - SERVER_START_REQ( set_socket_deferred ) - { - req->handle = wine_server_obj_handle( SOCKET2HANDLE(s) ); - req->deferred = wine_server_obj_handle( SOCKET2HANDLE(cs) ); - if ( !wine_server_call_err ( req ) ) - { - SetLastError( WSATRY_AGAIN ); - WS_closesocket( cs ); - } - } - SERVER_END_REQ; - return SOCKET_ERROR; + { + obj_handle_t server_handle = cs; + IO_STATUS_BLOCK io; + NTSTATUS status; + + status = NtDeviceIoControlFile( (HANDLE)s, NULL, NULL, NULL, &io, IOCTL_AFD_WINE_DEFER, + &server_handle, sizeof(server_handle), NULL, 0 ); + SetLastError( status ? RtlNtStatusToDosError( status ) : WSATRY_AGAIN ); + return -1; + }
case CF_REJECT: WS_closesocket( cs );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92719
Your paranoid android.
=== debiant2 (32 bit Hebrew:Israel report) ===
ws2_32: sock.c:4767: Test failed: expected timeout
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- server/protocol.def | 6 ------ server/sock.c | 18 ------------------ 2 files changed, 24 deletions(-)
diff --git a/server/protocol.def b/server/protocol.def index d3f44482c37..72f2f2c20ae 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1445,12 +1445,6 @@ enum server_fd_type @END
-@REQ(set_socket_deferred) - obj_handle_t handle; /* handle to the socket */ - obj_handle_t deferred; /* handle to the socket for which accept() is deferred */ -@END - - /* Perform a recv on a socket */ @REQ(recv_socket) int oob; /* are we receiving OOB data? */ diff --git a/server/sock.c b/server/sock.c index 7b40b6e3f30..547287572d5 100644 --- a/server/sock.c +++ b/server/sock.c @@ -2950,24 +2950,6 @@ DECL_HANDLER(get_socket_event) release_object( &sock->obj ); }
-DECL_HANDLER(set_socket_deferred) -{ - struct sock *sock, *acceptsock; - - sock=(struct sock *)get_handle_obj( current->process, req->handle, FILE_WRITE_ATTRIBUTES, &sock_ops ); - if ( !sock ) - return; - - acceptsock = (struct sock *)get_handle_obj( current->process, req->deferred, 0, &sock_ops ); - if ( !acceptsock ) - { - release_object( sock ); - return; - } - sock->deferred = acceptsock; - release_object( sock ); -} - DECL_HANDLER(get_socket_info) { struct sock *sock;