Zebediah Figura : ws2_32: Properly implement getsockopt(SO_CONNECT_TIME).
Alexandre Julliard
julliard at winehq.org
Thu Aug 19 16:00:06 CDT 2021
Module: wine
Branch: master
Commit: eec47af63865ceb9eb24b3c5d9a628027b4965c1
URL: https://source.winehq.org/git/wine.git/?a=commit;h=eec47af63865ceb9eb24b3c5d9a628027b4965c1
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Wed Aug 18 23:25:50 2021 -0500
ws2_32: Properly implement getsockopt(SO_CONNECT_TIME).
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ws2_32/socket.c | 29 ++++++++---------------------
include/wine/afd.h | 1 +
server/sock.c | 17 +++++++++++++++++
3 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/dlls/ws2_32/socket.c b/dlls/ws2_32/socket.c
index fd6ea25c751..30f233fa78f 100644
--- a/dlls/ws2_32/socket.c
+++ b/dlls/ws2_32/socket.c
@@ -1424,6 +1424,14 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
return 0;
}
+ case SO_CONNECT_TIME:
+ if (!optlen || !optval)
+ {
+ SetLastError( WSAEFAULT );
+ return -1;
+ }
+ return server_getsockopt( s, IOCTL_AFD_WINE_GET_SO_CONNECT_TIME, optval, optlen );
+
case SO_DEBUG:
WARN( "returning 0 for SO_DEBUG\n" );
*(DWORD *)optval = 0;
@@ -1450,27 +1458,6 @@ int WINAPI getsockopt( SOCKET s, int level, int optname, char *optval, int *optl
return ret;
}
- case SO_CONNECT_TIME:
- {
- static int pretendtime = 0;
- struct sockaddr addr;
- int len = sizeof(addr);
-
- if (!optlen || *optlen < sizeof(DWORD) || !optval)
- {
- SetLastError(WSAEFAULT);
- return SOCKET_ERROR;
- }
- if (getpeername(s, &addr, &len) == SOCKET_ERROR)
- *(DWORD *)optval = ~0u;
- else
- {
- if (!pretendtime) FIXME("SO_CONNECT_TIME - faking results\n");
- *(DWORD *)optval = pretendtime++;
- }
- *optlen = sizeof(DWORD);
- return ret;
- }
/* As mentioned in setsockopt, Windows ignores this, so we
* always return true here */
case SO_DONTROUTE:
diff --git a/include/wine/afd.h b/include/wine/afd.h
index 49bbcccd3af..e67ecae25a9 100644
--- a/include/wine/afd.h
+++ b/include/wine/afd.h
@@ -233,6 +233,7 @@ struct afd_get_events_params
#define IOCTL_AFD_WINE_SET_IPV6_RECVPKTINFO WINE_AFD_IOC(289)
#define IOCTL_AFD_WINE_GET_IPV6_RECVTCLASS WINE_AFD_IOC(290)
#define IOCTL_AFD_WINE_SET_IPV6_RECVTCLASS WINE_AFD_IOC(291)
+#define IOCTL_AFD_WINE_GET_SO_CONNECT_TIME WINE_AFD_IOC(292)
struct afd_create_params
{
diff --git a/server/sock.c b/server/sock.c
index 27477200ed0..50bfc08e145 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -2807,6 +2807,23 @@ static int sock_ioctl( struct fd *fd, ioctl_code_t code, struct async *async )
return 0;
}
+ case IOCTL_AFD_WINE_GET_SO_CONNECT_TIME:
+ {
+ DWORD time = ~0u;
+
+ if (get_reply_max_size() < sizeof(time))
+ {
+ set_error( STATUS_BUFFER_TOO_SMALL );
+ return 0;
+ }
+
+ if (sock->state == SOCK_CONNECTED)
+ time = (current_time - sock->connect_time) / 10000000;
+
+ set_reply_data( &time, sizeof(time) );
+ return 1;
+ }
+
default:
set_error( STATUS_NOT_SUPPORTED );
return 0;
More information about the wine-cvs
mailing list