Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Unified Diff: trunk/src/net/udp/udp_socket_win.cc

Issue 227083002: Revert 261966 "make SetReceiveBufferSize and SetSendBufferSize r..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/net/udp/udp_socket_win.h ('k') | trunk/src/remoting/jingle_glue/chromium_socket_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/net/udp/udp_socket_win.cc
===================================================================
--- trunk/src/net/udp/udp_socket_win.cc (revision 262001)
+++ trunk/src/net/udp/udp_socket_win.cc (working copy)
@@ -388,47 +388,44 @@
return OK;
}
-int UDPSocketWin::SetReceiveBufferSize(int32 size) {
+bool UDPSocketWin::SetReceiveBufferSize(int32 size) {
DCHECK(CalledOnValidThread());
- int rv = setsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
- reinterpret_cast<const char*>(&size), sizeof(size));
- if (rv != 0)
- return MapSystemError(WSAGetLastError());
-
- // According to documentation, setsockopt may succeed, but we need to check
- // the results via getsockopt to be sure it works on Windows.
+ 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);
- rv = getsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
- reinterpret_cast<char*>(&actual_size), &option_size);
+ int rv = getsockopt(socket_, SOL_SOCKET, SO_RCVBUF,
+ reinterpret_cast<char*>(&actual_size), &option_size);
if (rv != 0)
- return MapSystemError(WSAGetLastError());
- if (actual_size >= size)
- return OK;
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableReceiveBuffer",
- actual_size, 1000, 1000000, 50);
- return ERR_SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE;
+ return false;
+ if (actual_size < size) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketReceiveBufferUnchangeable",
+ actual_size, 1000, 1000000, 50);
+ }
+ return actual_size >= size;
}
-int UDPSocketWin::SetSendBufferSize(int32 size) {
+bool UDPSocketWin::SetSendBufferSize(int32 size) {
DCHECK(CalledOnValidThread());
- int rv = setsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
- reinterpret_cast<const char*>(&size), sizeof(size));
- if (rv != 0)
- return MapSystemError(WSAGetLastError());
- // According to documentation, setsockopt may succeed, but we need to check
- // the results via getsockopt to be sure it works on Windows.
+ 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);
- rv = getsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
- reinterpret_cast<char*>(&actual_size), &option_size);
+ int rv = getsockopt(socket_, SOL_SOCKET, SO_SNDBUF,
+ reinterpret_cast<char*>(&actual_size), &option_size);
if (rv != 0)
- return MapSystemError(WSAGetLastError());
- if (actual_size >= size)
- return OK;
- UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableSendBuffer",
- actual_size, 1000, 1000000, 50);
- return ERR_SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE;
+ return false;
+ if (actual_size < size) {
+ UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SocketUnchangeableSendBuffer",
+ actual_size, 1000, 1000000, 50);
+ }
+ return actual_size >= size;
}
void UDPSocketWin::AllowAddressReuse() {
« no previous file with comments | « trunk/src/net/udp/udp_socket_win.h ('k') | trunk/src/remoting/jingle_glue/chromium_socket_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698