Author: phater
Date: Thu Nov 10 17:55:00 2016
New Revision: 73197
URL:
http://svn.reactos.org/svn/reactos?rev=73197&view=rev
Log:
[MSAFD] Implement SO_CONNECT_TIME. CORE-12104
Modified:
trunk/reactos/dll/win32/msafd/misc/dllmain.c
trunk/reactos/dll/win32/msafd/msafd.h
Modified: trunk/reactos/dll/win32/msafd/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/misc/dllma…
==============================================================================
--- trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/misc/dllmain.c [iso-8859-1] Thu Nov 10 17:55:00 2016
@@ -1320,6 +1320,21 @@
return HandleCount;
}
+DWORD
+GetCurrentTimeInSeconds()
+{
+ FILETIME Time;
+ FILETIME Adjustment;
+ ULARGE_INTEGER lTime, lAdj;
+ SYSTEMTIME st = { 1970,1,0,1,0,0,0 };
+ SystemTimeToFileTime(&st, &Adjustment);
+ memcpy(&lAdj, &Adjustment, sizeof(lAdj));
+ GetSystemTimeAsFileTime(&Time);
+ memcpy(&lTime, &Time, sizeof(lTime));
+ lTime.QuadPart -= lAdj.QuadPart;
+ return (DWORD)(lTime.QuadPart / 10000000LLU);
+}
+
SOCKET
WSPAPI
WSPAccept(SOCKET Handle,
@@ -1666,6 +1681,7 @@
}
AcceptSocketInfo->SharedData->State = SocketConnected;
+ AcceptSocketInfo->SharedData->ConnectTime = GetCurrentTimeInSeconds();
/* Return Address in SOCKADDR FORMAT */
if( SocketAddress )
@@ -1884,6 +1900,7 @@
Socket->SharedData->State = SocketConnected;
Socket->TdiConnectionHandle = (HANDLE)IOSB.Information;
+ Socket->SharedData->ConnectTime = GetCurrentTimeInSeconds();
/* Get any pending connect data */
if (lpCalleeData != NULL)
@@ -2437,6 +2454,7 @@
PVOID Buffer;
INT BufferSize;
BOOL BoolBuffer;
+ DWORD DwordBuffer;
INT Errno;
TRACE("Called\n");
@@ -2540,6 +2558,12 @@
case SO_ERROR:
Buffer = &Socket->SharedData->SocketLastError;
BufferSize = sizeof(INT);
+ break;
+
+ case SO_CONNECT_TIME:
+ DwordBuffer = GetCurrentTimeInSeconds() -
Socket->SharedData->ConnectTime;
+ Buffer = &DwordBuffer;
+ BufferSize = sizeof(DWORD);
break;
case SO_SNDTIMEO:
Modified: trunk/reactos/dll/win32/msafd/msafd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/msafd/msafd.h?re…
==============================================================================
--- trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/msafd/msafd.h [iso-8859-1] Thu Nov 10 17:55:00 2016
@@ -59,6 +59,7 @@
ULONG RecvTimeout;
ULONG SizeOfRecvBuffer;
ULONG SizeOfSendBuffer;
+ ULONG ConnectTime;
struct {
BOOLEAN Listening:1;
BOOLEAN Broadcast:1;