diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 18:02:56 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 18:02:56 +0000 |
commit | 6b0c5e6c1b1616212e8649ed5339c14390c6d0fb (patch) | |
tree | 6e33c2ce1799f8af6abec7344e141bc60aba6e26 | |
parent | 30d32c936fe9ca1f24a555d4ffb77f703607aaa1 (diff) | |
download | chromium_src-6b0c5e6c1b1616212e8649ed5339c14390c6d0fb.zip chromium_src-6b0c5e6c1b1616212e8649ed5339c14390c6d0fb.tar.gz chromium_src-6b0c5e6c1b1616212e8649ed5339c14390c6d0fb.tar.bz2 |
Assert that the WinSock DLL supports version 2.2.
R=cpu
Review URL: http://codereview.chromium.org/67111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13672 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/base/winsock_init.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/net/base/winsock_init.cc b/net/base/winsock_init.cc index 190ed77..5c3f005 100644 --- a/net/base/winsock_init.cc +++ b/net/base/winsock_init.cc @@ -6,6 +6,7 @@ #include "net/base/winsock_init.h" +#include "base/logging.h" #include "base/singleton.h" namespace { @@ -13,17 +14,21 @@ namespace { class WinsockInitSingleton { public: WinsockInitSingleton() : did_init_(false) { - WORD winsock_ver = MAKEWORD(2,2); + WORD winsock_ver = MAKEWORD(2, 2); WSAData wsa_data; did_init_ = (WSAStartup(winsock_ver, &wsa_data) == 0); - - // The first time WSAGetLastError is called, the delay load helper will - // resolve the address with GetProcAddress and fixup the import. If a third - // party application hooks system functions without correctly restoring the - // error code, it is possible that the error code will be overwritten during - // delay load resolution. The result of the first call may be incorrect, so - // make sure the function is bound and future results will be correct. - WSAGetLastError(); + if (did_init_) { + DCHECK(wsa_data.wVersion == winsock_ver); + + // The first time WSAGetLastError is called, the delay load helper will + // resolve the address with GetProcAddress and fixup the import. If a + // third party application hooks system functions without correctly + // restoring the error code, it is possible that the error code will be + // overwritten during delay load resolution. The result of the first + // call may be incorrect, so make sure the function is bound and future + // results will be correct. + WSAGetLastError(); + } } ~WinsockInitSingleton() { |