diff options
author | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 03:02:05 +0000 |
---|---|---|
committer | jar@chromium.org <jar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-24 03:02:05 +0000 |
commit | 86a3c75fb644ceeda66ff8dae241c2a2db71bbc2 (patch) | |
tree | 694ed438f1f3f12281f30c86b50d6fb359430d18 /net/udp/udp_socket_win.cc | |
parent | 1ba083778992044511d32f1405f8d78de95561e6 (diff) | |
download | chromium_src-86a3c75fb644ceeda66ff8dae241c2a2db71bbc2.zip chromium_src-86a3c75fb644ceeda66ff8dae241c2a2db71bbc2.tar.gz chromium_src-86a3c75fb644ceeda66ff8dae241c2a2db71bbc2.tar.bz2 |
Check return results for setting socket buffer sizes in QUIC
...and
More aggressively validate that setsockopt(buffersize) worked on Windows.
Add histograms to monitor the impact of this change.
r=rch,wtc
BUG=355222
Review URL: https://codereview.chromium.org/196393003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258859 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/udp/udp_socket_win.cc')
-rw-r--r-- | net/udp/udp_socket_win.cc | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/net/udp/udp_socket_win.cc b/net/udp/udp_socket_win.cc index beaf400..5c8bff4 100644 --- a/net/udp/udp_socket_win.cc +++ b/net/udp/udp_socket_win.cc @@ -390,18 +390,42 @@ int UDPSocketWin::CreateSocket(int addr_family) { bool UDPSocketWin::SetReceiveBufferSize(int32 size) { DCHECK(CalledOnValidThread()); - int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, - reinterpret_cast<const char*>(&size), sizeof(size)); - DCHECK(!rv) << "Could not set socket receive buffer size: " << errno; - return rv == 0; + setsockopt(socket_, SOL_SOCKET, SO_RCVBUF, + reinterpret_cast<const char*>(&size), sizeof(size)); + // If the setsockopt fails, but the buffer is big enough, we will return + // success. It is not worth testing the return value as we still need to check + // via getsockopt anyway according to Windows documentation. + int32 actual_size = 0; + int option_size = sizeof(actual_size); + int rv = getsockopt(socket_, SOL_SOCKET, SO_RCVBUF, + reinterpret_cast<char*>(&actual_size), &option_size); + if (rv != 0) + return false; + if (actual_size < size) { + UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketReceiveBufferUnchangeable", + actual_size, 1000, 1000000, 50); + } + return actual_size >= size; } bool UDPSocketWin::SetSendBufferSize(int32 size) { DCHECK(CalledOnValidThread()); - int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, - reinterpret_cast<const char*>(&size), sizeof(size)); - DCHECK(!rv) << "Could not set socket send buffer size: " << errno; - return rv == 0; + setsockopt(socket_, SOL_SOCKET, SO_SNDBUF, + reinterpret_cast<const char*>(&size), sizeof(size)); + // If the setsockopt fails, but the buffer is big enough, we will return + // success. It is not worth testing the return value as we still need to check + // via getsockopt anyway according to Windows documentation. + int32 actual_size = 0; + int option_size = sizeof(actual_size); + int rv = getsockopt(socket_, SOL_SOCKET, SO_SNDBUF, + reinterpret_cast<char*>(&actual_size), &option_size); + if (rv != 0) + return false; + if (actual_size < size) { + UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableSendBuffer", + actual_size, 1000, 1000000, 50); + } + return actual_size >= size; } void UDPSocketWin::AllowAddressReuse() { |