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

Unified Diff: native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc

Issue 304373008: Add support for modifying TCP and UDP socket buffer size in nacl_io (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Corrected the unit tests Created 6 years, 7 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
Index: native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
index 807529d8af56cfafc9ec6718070c162a5b443ddb..a736a883ff3050b37c64a5800f75526870fcf6d2 100644
--- a/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
+++ b/native_client_sdk/src/libraries/nacl_io/socket/udp_node.cc
@@ -194,6 +194,37 @@ void UdpNode::QueueOutput() {
stream()->EnqueueWork(work);
}
+Error UdpNode::SetSockOpt(int lvl,
+ int optname,
+ const void* optval,
+ socklen_t len) {
+ if (lvl == SOL_SOCKET && optname == SO_RCVBUF) {
+ if (static_cast<size_t>(len) < sizeof(int))
+ return EINVAL;
+ AUTO_LOCK(node_lock_);
+ int bufsize = *static_cast<const int*>(optval);
+ int32_t error =
+ UDPInterface()->SetOption(socket_resource_,
+ PP_UDPSOCKET_OPTION_RECV_BUFFER_SIZE,
+ PP_MakeInt32(bufsize),
+ PP_BlockUntilComplete());
+ return PPErrorToErrno(error);
+ } else if (lvl == SOL_SOCKET && optname == SO_SNDBUF) {
+ if (static_cast<size_t>(len) < sizeof(int))
+ return EINVAL;
+ AUTO_LOCK(node_lock_);
+ int bufsize = *static_cast<const int*>(optval);
+ int32_t error =
+ UDPInterface()->SetOption(socket_resource_,
+ PP_UDPSOCKET_OPTION_SEND_BUFFER_SIZE,
+ PP_MakeInt32(bufsize),
+ PP_BlockUntilComplete());
+ return PPErrorToErrno(error);
+ }
+
+ return SocketNode::SetSockOpt(lvl, optname, optval, len);
+}
+
Error UdpNode::Bind(const struct sockaddr* addr, socklen_t len) {
if (0 == socket_resource_)
return EBADF;

Powered by Google App Engine
This is Rietveld 408576698