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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/socket/tcp_node.cc

Issue 176923017: [NaCl SDK] Compile for naclio for Bionic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bug in h_error 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 void TcpNode::SetError_Locked(int pp_error_num) { 312 void TcpNode::SetError_Locked(int pp_error_num) {
313 SocketNode::SetError_Locked(pp_error_num); 313 SocketNode::SetError_Locked(pp_error_num);
314 emitter_->SetError_Locked(); 314 emitter_->SetError_Locked();
315 } 315 }
316 316
317 Error TcpNode::GetSockOpt(int lvl, int optname, void* optval, socklen_t* len) { 317 Error TcpNode::GetSockOpt(int lvl, int optname, void* optval, socklen_t* len) {
318 if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) { 318 if (lvl == IPPROTO_TCP && optname == TCP_NODELAY) {
319 AUTO_LOCK(node_lock_); 319 AUTO_LOCK(node_lock_);
320 int value = tcp_nodelay_; 320 int value = tcp_nodelay_;
321 socklen_t value_len = sizeof(value); 321 socklen_t value_len = static_cast<socklen_t>(sizeof(value));
322 int copy_bytes = std::min(value_len, *len); 322 int copy_bytes = std::min(value_len, *len);
323 memcpy(optval, &value, copy_bytes); 323 memcpy(optval, &value, copy_bytes);
324 *len = value_len; 324 *len = value_len;
325 return 0; 325 return 0;
326 } 326 }
327 327
328 return SocketNode::GetSockOpt(lvl, optname, optval, len); 328 return SocketNode::GetSockOpt(lvl, optname, optval, len);
329 } 329 }
330 330
331 Error TcpNode::SetNoDelay_Locked() { 331 Error TcpNode::SetNoDelay_Locked() {
332 if (!IsConnected()) 332 if (!IsConnected())
333 return 0; 333 return 0;
334 334
335 int32_t error = 335 int32_t error =
336 TCPInterface()->SetOption(socket_resource_, 336 TCPInterface()->SetOption(socket_resource_,
337 PP_TCPSOCKET_OPTION_NO_DELAY, 337 PP_TCPSOCKET_OPTION_NO_DELAY,
338 PP_MakeBool(tcp_nodelay_ ? PP_TRUE : PP_FALSE), 338 PP_MakeBool(tcp_nodelay_ ? PP_TRUE : PP_FALSE),
339 PP_BlockUntilComplete()); 339 PP_BlockUntilComplete());
340 return PPErrorToErrno(error); 340 return PPErrorToErrno(error);
341 } 341 }
342 342
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 (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 } 353 }
354 354
355 return SocketNode::SetSockOpt(lvl, optname, optval, len); 355 return SocketNode::SetSockOpt(lvl, optname, optval, len);
356 } 356 }
357 357
358 void TcpNode::QueueAccept() { 358 void TcpNode::QueueAccept() {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 assert(emitter_.get()); 548 assert(emitter_.get());
549 if (emitter_->GetError_Locked()) 549 if (emitter_->GetError_Locked())
550 return EPIPE; 550 return EPIPE;
551 *out_len = emitter_->WriteOut_Locked((char*)buf, len); 551 *out_len = emitter_->WriteOut_Locked((char*)buf, len);
552 return 0; 552 return 0;
553 } 553 }
554 554
555 } // namespace nacl_io 555 } // namespace nacl_io
556 556
557 #endif // PROVIDES_SOCKET_API 557 #endif // PROVIDES_SOCKET_API
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698