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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |