diff --git a/bin/release/redis-2.8.9.zip b/bin/release/redis-2.8.9.zip index d329abbf..af03237a 100644 Binary files a/bin/release/redis-2.8.9.zip and b/bin/release/redis-2.8.9.zip differ diff --git a/msvs/RedisBenchmark/RedisBenchmark.vcxproj b/msvs/RedisBenchmark/RedisBenchmark.vcxproj index 935aaad0..6ed7a626 100644 --- a/msvs/RedisBenchmark/RedisBenchmark.vcxproj +++ b/msvs/RedisBenchmark/RedisBenchmark.vcxproj @@ -34,7 +34,7 @@ Application true MultiByte - v120 + v120_xp Application @@ -48,7 +48,7 @@ false true MultiByte - v120 + v120_xp @@ -109,7 +109,7 @@ Level3 Disabled - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP;_WIN32_WINNT=0x0501 $(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src MultiThreadedDebug 4996 @@ -155,7 +155,7 @@ MaxSpeed true true - _WIN32IOCP;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL + _WIN32IOCP;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL;_WIN32_WINNT=0x0501 $(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\lua\src MultiThreaded 4996 diff --git a/msvs/RedisCheckAof/RedisCheckAof.vcxproj b/msvs/RedisCheckAof/RedisCheckAof.vcxproj index 5c3ead7f..2d63e98b 100644 --- a/msvs/RedisCheckAof/RedisCheckAof.vcxproj +++ b/msvs/RedisCheckAof/RedisCheckAof.vcxproj @@ -33,7 +33,7 @@ Application true MultiByte - v120 + v120_xp Application @@ -47,7 +47,7 @@ false true MultiByte - v120 + v120_xp @@ -101,7 +101,7 @@ Level3 Disabled - WIN32;_DEBUG;_CONSOLE;USE_DL_PREFIX;LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP + WIN32;_DEBUG;_CONSOLE;USE_DL_PREFIX;LACKS_STDLIB_H;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP;_WIN32_WINNT=0x0501 4996 MultiThreadedDebug $(SolutionDir)..\deps\lua\src @@ -113,6 +113,7 @@ false MSVCRT UseLinkTimeCodeGeneration + Console @@ -141,7 +142,7 @@ MaxSpeed true true - WIN32;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;USE_DL_PREFIX;LACKS_STDLIB_H;NO_QFORKIMPL + WIN32;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;USE_DL_PREFIX;LACKS_STDLIB_H;NO_QFORKIMPL;_WIN32_WINNT=0x0501 4996 MultiThreaded $(SolutionDir)..\deps\lua\src @@ -153,6 +154,7 @@ $(OutDir)redis-check-aof$(TargetExt) kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) false + Console diff --git a/msvs/RedisCheckDump/RedisCheckDump.vcxproj b/msvs/RedisCheckDump/RedisCheckDump.vcxproj index df2e8092..24eb391c 100644 --- a/msvs/RedisCheckDump/RedisCheckDump.vcxproj +++ b/msvs/RedisCheckDump/RedisCheckDump.vcxproj @@ -33,7 +33,7 @@ Application true MultiByte - v120 + v120_xp Application @@ -47,7 +47,7 @@ false true MultiByte - v120 + v120_xp @@ -101,7 +101,7 @@ Level3 Disabled - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP;_WIN32_WINNT=0x0501 MultiThreadedDebug 4996 $(SolutionDir)..\deps\lua\src @@ -113,6 +113,7 @@ false UseLinkTimeCodeGeneration MSVCRT + Console @@ -141,7 +142,7 @@ MaxSpeed true true - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL;_WIN32_WINNT=0x0501 MultiThreaded 4996 $(SolutionDir)..\deps\lua\src @@ -153,6 +154,7 @@ $(OutDir)redis-check-dump$(TargetExt) kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) false + Console diff --git a/msvs/RedisCli/RedisCli.vcxproj b/msvs/RedisCli/RedisCli.vcxproj index e2f027e3..ef19f465 100644 --- a/msvs/RedisCli/RedisCli.vcxproj +++ b/msvs/RedisCli/RedisCli.vcxproj @@ -33,7 +33,7 @@ Application true MultiByte - v120 + v120_xp Application @@ -47,7 +47,7 @@ false true MultiByte - v120 + v120_xp @@ -103,7 +103,7 @@ Level3 Disabled $(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);NO_QFORKIMPL;WIN32_IOCP;_WIN32_WINNT=0x0501 MultiThreadedDebug 4996 @@ -115,6 +115,7 @@ false MSVCRT UseLinkTimeCodeGeneration + Console @@ -145,7 +146,7 @@ true true $(SolutionDir)..\deps\hiredis;$(SolutionDir)..\deps\linenoise;$(SolutionDir)..\deps\lua\src - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;NO_QFORKIMPL;_WIN32_WINNT=0x0501 MultiThreaded 4996 @@ -157,6 +158,7 @@ $(OutDir);$(OutDir)lib kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) false + Console diff --git a/msvs/RedisServer.vcxproj b/msvs/RedisServer.vcxproj index c9a5c359..bf713387 100644 --- a/msvs/RedisServer.vcxproj +++ b/msvs/RedisServer.vcxproj @@ -32,7 +32,7 @@ Application true - v120 + v120_xp false @@ -43,7 +43,7 @@ Application false - v120 + v120_xp @@ -104,7 +104,7 @@ - WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC;WIN32_IOCP + WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;_DEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);USE_DLMALLOC;WIN32_IOCP;_WIN32_WINNT=0x0501 $(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis MultiThreadedDebug Level3 @@ -149,7 +149,7 @@ - _WIN32IOCP;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);WIN32_IOCP;USE_DLMALLOC + _WIN32IOCP;WIN32;USE_DL_PREFIX;LACKS_STDLIB_H;NDEBUG;_CONSOLE;__x86_64__;%(PreprocessorDefinitions);WIN32_IOCP;USE_DLMALLOC;_WIN32_WINNT=0x0501 $(SolutionDir)..\deps\lua\src;$(SolutionDir)..\deps\hiredis MultiThreaded Level3 diff --git a/msvs/hiredis/hiredis.vcxproj b/msvs/hiredis/hiredis.vcxproj index 9f25c293..ff9ca00e 100644 --- a/msvs/hiredis/hiredis.vcxproj +++ b/msvs/hiredis/hiredis.vcxproj @@ -34,7 +34,7 @@ StaticLibrary true MultiByte - v120 + v120_xp StaticLibrary @@ -48,7 +48,7 @@ false true MultiByte - v120 + v120_xp @@ -97,7 +97,7 @@ NotUsing Level3 Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);WIN32_IOCP + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);WIN32_IOCP;_WIN32_WINNT=0x0501 MultiThreadedDebug 4996 @@ -131,7 +131,7 @@ MaxSpeed true true - WIN32;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP + WIN32;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;_WIN32_WINNT=0x0501 MultiThreaded 4996 diff --git a/msvs/lua/lua/lua.vcxproj b/msvs/lua/lua/lua.vcxproj index 98781858..9e634f0a 100644 --- a/msvs/lua/lua/lua.vcxproj +++ b/msvs/lua/lua/lua.vcxproj @@ -37,7 +37,7 @@ true false MultiByte - v120 + v120_xp StaticLibrary @@ -51,7 +51,7 @@ false false MultiByte - v120 + v120_xp @@ -104,7 +104,7 @@ Level3 Disabled - WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);WIN32_IOCP + WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);WIN32_IOCP;_WIN32_WINNT=0x0501 NotUsing MultiThreadedDebug 4244;4018 @@ -132,7 +132,7 @@ Level3 - WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP + WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions);WIN32_IOCP;WIN32_IOCP;_WIN32_WINNT=0x0501 NotUsing MultiThreaded 4244;4018 diff --git a/src/Win32_Interop/WS2tcpip.h b/src/Win32_Interop/WS2tcpip.h index 6dfb421e..4c15596a 100644 --- a/src/Win32_Interop/WS2tcpip.h +++ b/src/Win32_Interop/WS2tcpip.h @@ -44,7 +44,12 @@ #if _MSC_VER > 1000 #pragma once #endif + +#if WINVER <= _WIN32_WINNT_WS03 +#include "win32_winapifamily.h" +#else #include +#endif #pragma region Desktop Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) diff --git a/src/Win32_Interop/Win32_FDAPI.cpp b/src/Win32_Interop/Win32_FDAPI.cpp index 27393ad7..5a7b2974 100644 --- a/src/Win32_Interop/Win32_FDAPI.cpp +++ b/src/Win32_Interop/Win32_FDAPI.cpp @@ -178,7 +178,11 @@ bool IsWindowsVersionAtLeast(WORD wMajorVersion, WORD wMinorVersion, WORD wServi } void EnableFastLoopback(SOCKET s) { - // if Win8+, use fast path option on loopback +#ifndef _WIN32_WINNT_WIN8 + #define _WIN32_WINNT_WIN8 0x0602 +#endif + + // if Win8+, use fast path option on loopback if (IsWindowsVersionAtLeast(HIBYTE(_WIN32_WINNT_WIN8), LOBYTE(_WIN32_WINNT_WIN8), 0)) { #ifndef SIO_LOOPBACK_FAST_PATH const DWORD SIO_LOOPBACK_FAST_PATH = 0x98000010; // from Win8 SDK @@ -401,7 +405,8 @@ int redis_fcntl_impl(int fd, int cmd, int flags = 0 ) { return -1; } -auto f_WSAPoll = dllfunctor_stdcall("ws2_32.dll", "WSAPoll"); +#undef FD_ISSET +#define FD_ISSET(fd, set) f_WSAFDIsSet((SOCKET)(fd), (fd_set *)(set)) int redis_poll_impl(struct pollfd *fds, nfds_t nfds, int timeout) { try { struct pollfd* pollCopy = new struct pollfd[nfds]; @@ -409,7 +414,7 @@ int redis_poll_impl(struct pollfd *fds, nfds_t nfds, int timeout) { errno = ENOMEM; return -1; } - + // NOTE: Treating the fds.fd as a Redis file descriptor and converting to a SOCKET for WSAPoll. for (nfds_t n = 0; n < nfds; n ++) { pollCopy[n].fd = RFDMap::getInstance().lookupSocket((RFD)(fds[n].fd)); @@ -417,19 +422,88 @@ int redis_poll_impl(struct pollfd *fds, nfds_t nfds, int timeout) { pollCopy[n].revents = fds[n].revents; } - // See the community addition comments at http://msdn.microsoft.com/en-us/library/windows/desktop/ms741669%28v=vs.85%29.aspx for this API. - // BugCheck seems to indicate that problems with this API in Win8 have been addressed, but this needs to be verified. - int ret = f_WSAPoll(pollCopy, nfds, timeout); + if (IsWindowsVersionAtLeast(HIBYTE(_WIN32_WINNT_WIN6), LOBYTE(_WIN32_WINNT_WIN6), 0)) { + static auto f_WSAPoll = dllfunctor_stdcall("ws2_32.dll", "WSAPoll"); - for (nfds_t n = 0; n < nfds; n ++) { - fds[n].events = pollCopy[n].events; - fds[n].revents = pollCopy[n].revents; + // See the community addition comments at http://msdn.microsoft.com/en-us/library/windows/desktop/ms741669%28v=vs.85%29.aspx for this API. + // BugCheck seems to indicate that problems with this API in Win8 have been addressed, but this needs to be verified. + int ret = f_WSAPoll(pollCopy, nfds, timeout); + + for (nfds_t n = 0; n < nfds; n++) { + fds[n].events = pollCopy[n].events; + fds[n].revents = pollCopy[n].revents; + } + + delete pollCopy; + pollCopy = NULL; + + return ret; + } else { + static auto f_WSAFDIsSet = dllfunctor_stdcall("ws2_32.dll", "__WSAFDIsSet"); + + int ret; + fd_set readSet; + fd_set writeSet; + fd_set excepSet; + + FD_ZERO(&readSet); + FD_ZERO(&writeSet); + FD_ZERO(&excepSet); + + if (nfds >= FD_SETSIZE) { + errno = EINVAL; + return -1; + } + + int n = 0; + nfds_t i; + for (i = 0; i < nfds; i++) { + if (fds[i].fd < 0) { + continue; + } + if (pollCopy[i].fd >= FD_SETSIZE) { + errno = EINVAL; + return -1; + } + + if (pollCopy[i].events & POLLIN) FD_SET(pollCopy[i].fd, &readSet); + if (pollCopy[i].events & POLLOUT) FD_SET(pollCopy[i].fd, &writeSet); + if (pollCopy[i].events & POLLERR) FD_SET(pollCopy[i].fd, &excepSet); + if (pollCopy[i].fd >= n) { + n = pollCopy[i].fd + 1; + } + } + + if (n == 0) { + return 0; + } + + if (timeout < 0) { + ret = select(n, &readSet, &writeSet, &excepSet, NULL); + } else { + struct timeval tv; + tv.tv_sec = timeout / 1000; + tv.tv_usec = 1000 * (timeout % 1000); + ret = select(n, &readSet, &writeSet, &excepSet, &tv); + } + + if (ret < 0) { + return ret; + } + + for (i = 0; i < nfds; i++) { + fds[i].revents = 0; + + if (FD_ISSET(pollCopy[i].fd, &readSet)) fds[i].revents |= POLLIN; + if (FD_ISSET(pollCopy[i].fd, &writeSet)) fds[i].revents |= POLLOUT; + if (FD_ISSET(pollCopy[i].fd, &excepSet)) fds[i].revents |= POLLERR; + } + + delete pollCopy; + pollCopy = NULL; + + return ret; } - - delete pollCopy; - pollCopy = NULL; - - return ret; } CATCH_AND_REPORT() errno = EBADF; @@ -931,9 +1005,23 @@ int redis_getaddrinfo_impl(const char *node, const char *service, const struct a return f_getaddrinfo(node, service,hints, res); } -auto f_inet_ntop = dllfunctor_stdcall("ws2_32.dll", "inet_ntop"); const char* redis_inet_ntop_impl(int af, const void *src, char *dst, size_t size) { - return f_inet_ntop(af, src, dst, size); + if (IsWindowsVersionAtLeast(HIBYTE(_WIN32_WINNT_WIN6), LOBYTE(_WIN32_WINNT_WIN6), 0)) { + static auto f_inet_ntop = dllfunctor_stdcall("ws2_32.dll", "inet_ntop"); + return f_inet_ntop(af, src, dst, size); + } else { + static auto f_WSAAddressToStringA = dllfunctor_stdcall("ws2_32.dll", "WSAAddressToStringA"); + struct sockaddr_in srcaddr; + + memset(&srcaddr, 0, sizeof(struct sockaddr_in)); + memcpy(&(srcaddr.sin_addr), src, sizeof(srcaddr.sin_addr)); + + srcaddr.sin_family = af; + if (f_WSAAddressToStringA((struct sockaddr*) &srcaddr, sizeof(struct sockaddr_in), 0, dst, (LPDWORD)&size) != 0) { + return NULL; + } + return dst; + } } class Win32_FDSockMap { diff --git a/src/Win32_Interop/Win32_FDAPI.h b/src/Win32_Interop/Win32_FDAPI.h index b98faf41..298d6ee1 100644 --- a/src/Win32_Interop/Win32_FDAPI.h +++ b/src/Win32_Interop/Win32_FDAPI.h @@ -114,6 +114,29 @@ gai_strerrorW( return buff; } +#if WINVER <= _WIN32_WINNT_WS03 +#define POLLRDNORM 0x0100 +#define POLLRDBAND 0x0200 +#define POLLIN (POLLRDNORM | POLLRDBAND) +#define POLLPRI 0x0400 + +#define POLLWRNORM 0x0010 +#define POLLOUT (POLLWRNORM) +#define POLLWRBAND 0x0020 + +#define POLLERR 0x0001 +#define POLLHUP 0x0002 +#define POLLNVAL 0x0004 + +typedef struct pollfd { + + SOCKET fd; + SHORT events; + SHORT revents; + +} WSAPOLLFD, *PWSAPOLLFD, FAR *LPWSAPOLLFD; +#endif + // WinSock APIs used in Win32_wsiocp.cpp typedef int (*redis_WSASend)(int rfd, LPWSABUF lpBuffers, DWORD dwBufferCount, LPDWORD lpNumberOfBytesSent, DWORD dwFlags, LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); typedef int (*redis_WSARecv)(int rfd,LPWSABUF lpBuffers,DWORD dwBufferCount,LPDWORD lpNumberOfBytesRecvd,LPDWORD lpFlags,LPWSAOVERLAPPED lpOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine); diff --git a/src/Win32_Interop/Win32_Interop.vcxproj b/src/Win32_Interop/Win32_Interop.vcxproj index 971d6d7c..c0e7b245 100644 --- a/src/Win32_Interop/Win32_Interop.vcxproj +++ b/src/Win32_Interop/Win32_Interop.vcxproj @@ -47,6 +47,7 @@ + @@ -87,7 +88,7 @@ rc.exe -foresources/EventLog.res resources/EventLog.rc StaticLibrary true - v120 + v120_xp Unicode @@ -100,7 +101,7 @@ rc.exe -foresources/EventLog.res resources/EventLog.rc StaticLibrary false - v120 + v120_xp true Unicode @@ -147,7 +148,7 @@ rc.exe -foresources/EventLog.res resources/EventLog.rc Level3 Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC;_CRT_SECURE_NO_WARNINGS;WIN32_IOCP;PSAPI_VERSION=1 + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions);USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC;_CRT_SECURE_NO_WARNINGS;WIN32_IOCP;PSAPI_VERSION=1;_WIN32_WINNT=0x0501 $(ProjectDir)..\..\deps\lua\src MultiThreadedDebug @@ -192,7 +193,7 @@ rc.exe -foresources/EventLog.res resources/EventLog.rc MaxSpeed true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_WIN32IOCP;USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1 + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_WIN32IOCP;USE_DL_PREFIX;LACKS_STDLIB_H;USE_DLMALLOC;_CRT_SECURE_NO_WARNINGS;PSAPI_VERSION=1;_WIN32_WINNT=0x0501 $(ProjectDir)..\..\deps\lua\src MultiThreaded diff --git a/src/Win32_Interop/Win32_QFork.cpp b/src/Win32_Interop/Win32_QFork.cpp index d9efa16e..11e5f3c4 100644 --- a/src/Win32_Interop/Win32_QFork.cpp +++ b/src/Win32_Interop/Win32_QFork.cpp @@ -339,7 +339,7 @@ BOOL QForkMasterInit( __int64 maxheapBytes ) { DeleteFile(fd.cFileName); if (FALSE == FindNextFile(hFind, &fd)) { - CloseHandle(hFind); + FindClose(hFind); hFind = INVALID_HANDLE_VALUE; } } diff --git a/src/Win32_Interop/Win32_service.cpp b/src/Win32_Interop/Win32_service.cpp index 55c67eff..025cb10e 100644 --- a/src/Win32_Interop/Win32_service.cpp +++ b/src/Win32_Interop/Win32_service.cpp @@ -338,7 +338,7 @@ VOID ServiceStart(int argc, char ** argv) { Sleep(2000); SERVICE_STATUS status; - ULONGLONG start = GetTickCount64(); + DWORD start = GetTickCount(); while (QueryServiceStatus(shService, &status) == TRUE) { if (status.dwCurrentState == SERVICE_RUNNING) { WriteServiceInstallMessage("Redis service successfully started."); @@ -348,7 +348,7 @@ VOID ServiceStart(int argc, char ** argv) { break; } - ULONGLONG current = GetTickCount64(); + DWORD current = GetTickCount(); if (current - start >= cThirtySeconds) { WriteServiceInstallMessage("Redis service start timed out."); break; @@ -376,13 +376,13 @@ VOID ServiceStop(int argc, char ** argv) { throw std::system_error(GetLastError(), system_category(), "ControlService failed"); } - ULONGLONG start = GetTickCount64(); + DWORD start = GetTickCount(); while (QueryServiceStatus(shService, &status) == TRUE) { if (status.dwCurrentState == SERVICE_STOPPED) { WriteServiceInstallMessage("Redis service successfully stopped."); break; } - ULONGLONG current = GetTickCount64(); + DWORD current = GetTickCount(); if (current - start >= cThirtySeconds) { WriteServiceInstallMessage("Redis service stop timed out."); break; diff --git a/src/Win32_Interop/win32_winapifamily.h b/src/Win32_Interop/win32_winapifamily.h new file mode 100644 index 00000000..d12170bc --- /dev/null +++ b/src/Win32_Interop/win32_winapifamily.h @@ -0,0 +1,180 @@ +/* + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + +winapifamily.h + +Abstract: + +Master include file for API family partitioning. + +*/ + +#ifndef _INC_WINAPIFAMILY +#define _INC_WINAPIFAMILY + +#if defined(_MSC_VER) && !defined(MOFCOMP_PASS) +#pragma once +#endif // defined(_MSC_VER) && !defined(MOFCOMP_PASS) + +/* +* When compiling C and C++ code using SDK header files, the development +* environment can specify a target platform by #define-ing the +* pre-processor symbol WINAPI_FAMILY to one of the following values. +* Each FAMILY value denotes an application family for which a different +* subset of the total set of header-file-defined APIs are available. +* Setting the WINAPI_FAMILY value will effectively hide from the +* editing and compilation environments the existence of APIs that +* are not applicable to the family of applications targeting a +* specific platform. +*/ + +/* +* The WINAPI_FAMILY values of 0 and 1 are reserved to ensure that +* an error will occur if WINAPI_FAMILY is set to any +* WINAPI_PARTITION value (which must be 0 or 1, see below). +*/ +#define WINAPI_FAMILY_PC_APP 2 /* Windows Store Applications */ +#define WINAPI_FAMILY_PHONE_APP 3 /* Windows Phone Applications */ +#define WINAPI_FAMILY_DESKTOP_APP 100 /* Windows Desktop Applications */ +/* The value of WINAPI_FAMILY_DESKTOP_APP may change in future SDKs. */ +/* Additional WINAPI_FAMILY values may be defined in future SDKs. */ + +/* +* For compatibility with Windows 8 header files, the following +* synonym for WINAPI_FAMILY_PC_APP is temporarily #define'd. +* Use of this symbol should be considered deprecated. +*/ +#define WINAPI_FAMILY_APP WINAPI_FAMILY_PC_APP + +/* +* If no WINAPI_FAMILY value is specified, then all APIs available to +* Windows desktop applications are exposed. +*/ +#ifndef WINAPI_FAMILY +#define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP +#endif + +/* +* API PARTITONs are part of an indirection mechanism for mapping between +* individual APIs and the FAMILYs to which they apply. +* Each PARTITION is a category or subset of named APIs. PARTITIONs +* are permitted to have overlapping membership -- some single API +* might be part of more than one PARTITION. In support of new +* FAMILYs that might be added in future SDKs, any single current +* PARTITION might in that future SDK be split into two or more new PARTITIONs. +* Accordingly, application developers should avoid taking dependencies on +* PARTITION names; developers' only dependency upon the symbols defined +* in this file should be their reliance on the WINAPI_FAMILY names and values. +*/ + +/* +* Current PARTITIONS are each #undef'ed below, and then will be #define-ed +* to be either 1 or 0 or depending on the active WINAPI_FAMILY. +*/ + +#undef WINAPI_PARTITION_DESKTOP /* usable for PC desktop apps (but not store apps) */ +#undef WINAPI_PARTITION_APP /* usable for most platforms' store apps */ +#undef WINAPI_PARTITION_PC_APP /* specific to PC store apps */ +#undef WINAPI_PARTITION_PHONE_APP /* specific to phone store apps */ + + +/* +* The mapping between families and partitions is summarized here. +* An X indicates that the given partition is active for the given +* platform/family. +* +* +---------------+ +* | *Partition* | +* +---+---+---+---+ +* | | | | P | +* | | | | H | +* | D | | | O | +* | E | | P | N | +* | S | | C | E | +* | K | | _ | _ | +* | T | A | A | A | +* +-------------------------+-+ O | P | P | P | +* | *Platform/Family* \| P | P | P | P | +* +---------------------------+---+---+---+---+ +* | WINAPI_FAMILY_DESKTOP_APP | X | X | X | | +* +---------------------------+---+---+---+---+ +* | WINAPI_FAMILY_PC_APP | | X | X | | +* +---------------------------+---+---+---+---+ +* | WINAPI_FAMILY_PHONE_APP | | X | | X | +* +---------------------------+---+---+---+---+ +* +* The table above is encoded in the following expressions, +* each of which evaluates to 1 or 0. +* +* Whenever a new family is added, all of these expressions +* need to be reconsidered. +*/ +#if WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP && WINAPI_FAMILY != WINAPI_FAMILY_PC_APP && WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +# error Unknown WINAPI_FAMILY value. Was it defined in terms of a WINAPI_PARTITION_* value? +#endif +#define WINAPI_PARTITION_DESKTOP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) +#define WINAPI_PARTITION_APP 1 /* active for all current families */ +#define WINAPI_PARTITION_PC_APP (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP || WINAPI_FAMILY == WINAPI_FAMILY_PC_APP) +#define WINAPI_PARTITION_PHONE_APP (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) + +/* +* For compatibility with Windows Phone 8 header files, the following +* synonym for WINAPI_PARTITION_PHONE_APP is temporarily #define'd. +* Use of this symbol should be regarded as deprecated. +*/ +#define WINAPI_PARTITION_PHONE WINAPI_PARTITION_PHONE_APP + +/* +* Header files use the WINAPI_FAMILY_PARTITION macro to assign one or +* more declarations to some group of partitions. The macro chooses +* whether the preprocessor will emit or omit a sequence of declarations +* bracketed by an #if/#endif pair. All header file references to the +* WINAPI_PARTITION_* values should be in the form of occurrences of +* WINAPI_FAMILY_PARTITION(...). +* +* For example, the following usage of WINAPI_FAMILY_PARTITION identifies +* a sequence of declarations that are part of both the Windows Desktop +* Partition and the Windows-Phone-Specific Store Partition: +* +* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP) +* ... +* #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_PHONE_APP) +* +* The comment on the closing #endif allow tools as well as people to find the +* matching #ifdef properly. +* +* Usages of WINAPI_FAMILY_PARTITION may be combined, when the partitition definitions are +* related. In particular one might use declarations like +* +* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +* +* or +* +* #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) +* +* Direct references to WINAPI_PARTITION_ values (eg #if !WINAPI_FAMILY_PARTITION_...) +* should not be used. +*/ +#define WINAPI_FAMILY_PARTITION(Partitions) (Partitions) + +/* +* Macro used to #define or typedef a symbol used for selective deprecation +* of individual methods of a COM interfaces that are otherwise available +* for a given set of partitions. +*/ +#define _WINAPI_DEPRECATED_DECLARATION __declspec(deprecated("This API cannot be used in the context of the caller's application type.")) + +/* +* For compatibility with Windows 8 header files, the following +* symbol is temporarily conditionally #define'd. Additional symbols +* like this should be not defined in winapifamily.h, but rather should be +* introduced locally to the header files of the component that needs them. +*/ +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) +# define APP_DEPRECATED_HRESULT HRESULT _WINAPI_DEPRECATED_DECLARATION +#endif // WINAPIFAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) + +#endif /* !_INC_WINAPIFAMILY */ diff --git a/src/Win32_Interop/win32_wsiocp.c b/src/Win32_Interop/win32_wsiocp.c index a8716ef3..c14b328b 100644 --- a/src/Win32_Interop/win32_wsiocp.c +++ b/src/Win32_Interop/win32_wsiocp.c @@ -187,6 +187,7 @@ int aeWinReceiveDone(int fd) { aeSockState *sockstate; int result; WSABUF zreadbuf; + DWORD bytesReceived = 0; if ((sockstate = aeGetSockState(iocpState, fd)) == NULL) { errno = WSAEINVAL; @@ -206,7 +207,7 @@ int aeWinReceiveDone(int fd) { result = WSARecv(fd, &zreadbuf, 1, - NULL, + &bytesReceived, &wsarecvflags, &sockstate->ov_read, NULL); @@ -228,6 +229,7 @@ int aeWinSocketSend(int fd, char *buf, int len, aeSockState *sockstate; int result; asendreq *areq; + DWORD bytesSent = 0; sockstate = aeGetSockState(iocpState, fd); @@ -262,7 +264,7 @@ int aeWinSocketSend(int fd, char *buf, int len, result = WSASend(fd, &areq->wbuf, 1, - NULL, + &bytesSent, 0, &areq->ov, NULL);