OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "nacl_io/ossocket.h" | 5 #include "nacl_io/ossocket.h" |
6 #ifdef PROVIDES_SOCKET_API | 6 #ifdef PROVIDES_SOCKET_API |
7 | 7 |
8 #include <assert.h> | 8 #include <assert.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 Error TcpNode::SetSockOpt(int lvl, | 343 Error TcpNode::SetSockOpt(int lvl, |
344 int optname, | 344 int optname, |
345 const void* optval, | 345 const void* optval, |
346 socklen_t len) { | 346 socklen_t len) { |
347 if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) { | 347 if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) { |
348 if (static_cast<size_t>(len) < sizeof(int)) | 348 if (static_cast<size_t>(len) < sizeof(int)) |
349 return EINVAL; | 349 return EINVAL; |
350 AUTO_LOCK(node_lock_); | 350 AUTO_LOCK(node_lock_); |
351 tcp_nodelay_ = *static_cast<const int*>(optval) != 0; | 351 tcp_nodelay_ = *static_cast<const int*>(optval) != 0; |
352 return SetNoDelay_Locked(); | 352 return SetNoDelay_Locked(); |
| 353 } else if (lvl == SOL_SOCKET && optname == SO_RCVBUF) { |
| 354 if (static_cast<size_t>(len) < sizeof(int)) |
| 355 return EINVAL; |
| 356 AUTO_LOCK(node_lock_); |
| 357 int bufsize = *static_cast<const int*>(optval); |
| 358 int32_t error = |
| 359 TCPInterface()->SetOption(socket_resource_, |
| 360 PP_TCPSOCKET_OPTION_RECV_BUFFER_SIZE, |
| 361 PP_MakeInt32(bufsize), |
| 362 PP_BlockUntilComplete()); |
| 363 return PPErrorToErrno(error); |
| 364 } else if (lvl == SOL_SOCKET && optname == SO_SNDBUF) { |
| 365 if (static_cast<size_t>(len) < sizeof(int)) |
| 366 return EINVAL; |
| 367 AUTO_LOCK(node_lock_); |
| 368 int bufsize = *static_cast<const int*>(optval); |
| 369 int32_t error = |
| 370 TCPInterface()->SetOption(socket_resource_, |
| 371 PP_TCPSOCKET_OPTION_SEND_BUFFER_SIZE, |
| 372 PP_MakeInt32(bufsize), |
| 373 PP_BlockUntilComplete()); |
| 374 return PPErrorToErrno(error); |
353 } | 375 } |
354 | 376 |
355 return SocketNode::SetSockOpt(lvl, optname, optval, len); | 377 return SocketNode::SetSockOpt(lvl, optname, optval, len); |
356 } | 378 } |
357 | 379 |
358 void TcpNode::QueueAccept() { | 380 void TcpNode::QueueAccept() { |
359 StreamFs::Work* work = new TCPAcceptWork(stream(), emitter_); | 381 StreamFs::Work* work = new TCPAcceptWork(stream(), emitter_); |
360 stream()->EnqueueWork(work); | 382 stream()->EnqueueWork(work); |
361 } | 383 } |
362 | 384 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 assert(emitter_.get()); | 570 assert(emitter_.get()); |
549 if (emitter_->GetError_Locked()) | 571 if (emitter_->GetError_Locked()) |
550 return EPIPE; | 572 return EPIPE; |
551 *out_len = emitter_->WriteOut_Locked((char*)buf, len); | 573 *out_len = emitter_->WriteOut_Locked((char*)buf, len); |
552 return 0; | 574 return 0; |
553 } | 575 } |
554 | 576 |
555 } // namespace nacl_io | 577 } // namespace nacl_io |
556 | 578 |
557 #endif // PROVIDES_SOCKET_API | 579 #endif // PROVIDES_SOCKET_API |
OLD | NEW |