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

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

Issue 804993008: nacl_io: accept now allows addr and len to be NULL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove incorrect tests Created 5 years, 11 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
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 int s = emitter_->GetAcceptedSocket_Locked(); 446 int s = emitter_->GetAcceptedSocket_Locked();
447 // Non-blocking case. 447 // Non-blocking case.
448 if (s == 0) 448 if (s == 0)
449 return EAGAIN; 449 return EAGAIN;
450 450
451 // Consume the new socket and start listening for the next one 451 // Consume the new socket and start listening for the next one
452 *out_sock = s; 452 *out_sock = s;
453 emitter_->ClearEvents_Locked(POLLIN); 453 emitter_->ClearEvents_Locked(POLLIN);
454 454
455 // Set the out paramaters 455 // Set the out paramaters
456 PP_Resource remote_addr = TCPInterface()->GetRemoteAddress(*out_sock); 456 if (addr && len) {
457 *len = ResourceToSockAddr(remote_addr, *len, addr); 457 PP_Resource remote_addr = TCPInterface()->GetRemoteAddress(*out_sock);
458 filesystem_->ppapi()->ReleaseResource(remote_addr); 458 *len = ResourceToSockAddr(remote_addr, *len, addr);
459 filesystem_->ppapi()->ReleaseResource(remote_addr);
460 }
459 461
460 QueueAccept(); 462 QueueAccept();
461 return 0; 463 return 0;
462 } 464 }
463 465
464 // We can not bind a client socket with PPAPI. For now we ignore the 466 // We can not bind a client socket with PPAPI. For now we ignore the
465 // bind but report the correct address later, just in case someone is 467 // bind but report the correct address later, just in case someone is
466 // binding without really caring what the address is (for example to 468 // binding without really caring what the address is (for example to
467 // select a more optimized interface/route.) 469 // select a more optimized interface/route.)
468 Error TcpNode::Bind(const struct sockaddr* addr, socklen_t len) { 470 Error TcpNode::Bind(const struct sockaddr* addr, socklen_t len) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 assert(emitter_.get()); 601 assert(emitter_.get());
600 if (emitter_->GetError_Locked()) 602 if (emitter_->GetError_Locked())
601 return EPIPE; 603 return EPIPE;
602 *out_len = emitter_->WriteOut_Locked((char*)buf, len); 604 *out_len = emitter_->WriteOut_Locked((char*)buf, len);
603 return 0; 605 return 0;
604 } 606 }
605 607
606 } // namespace nacl_io 608 } // namespace nacl_io
607 609
608 #endif // PROVIDES_SOCKET_API 610 #endif // PROVIDES_SOCKET_API
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698