| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 int err = TCPInterface()->Bind( | 448 int err = TCPInterface()->Bind( |
| 449 socket_resource_, local_addr_, PP_BlockUntilComplete()); | 449 socket_resource_, local_addr_, PP_BlockUntilComplete()); |
| 450 | 450 |
| 451 // If we fail, release the local addr resource | 451 // If we fail, release the local addr resource |
| 452 if (err != PP_OK) { | 452 if (err != PP_OK) { |
| 453 filesystem_->ppapi()->ReleaseResource(local_addr_); | 453 filesystem_->ppapi()->ReleaseResource(local_addr_); |
| 454 local_addr_ = 0; | 454 local_addr_ = 0; |
| 455 return PPErrorToErrno(err); | 455 return PPErrorToErrno(err); |
| 456 } | 456 } |
| 457 | 457 |
| 458 local_addr_ = TCPInterface()->GetLocalAddress(socket_resource_); |
| 458 return 0; | 459 return 0; |
| 459 } | 460 } |
| 460 | 461 |
| 461 Error TcpNode::Connect(const HandleAttr& attr, | 462 Error TcpNode::Connect(const HandleAttr& attr, |
| 462 const struct sockaddr* addr, | 463 const struct sockaddr* addr, |
| 463 socklen_t len) { | 464 socklen_t len) { |
| 464 EventListenerLock wait(GetEventEmitter()); | 465 EventListenerLock wait(GetEventEmitter()); |
| 465 | 466 |
| 466 if (TestStreamFlags(SSF_CONNECTING)) | 467 if (TestStreamFlags(SSF_CONNECTING)) |
| 467 return EALREADY; | 468 return EALREADY; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 assert(emitter_.get()); | 571 assert(emitter_.get()); |
| 571 if (emitter_->GetError_Locked()) | 572 if (emitter_->GetError_Locked()) |
| 572 return EPIPE; | 573 return EPIPE; |
| 573 *out_len = emitter_->WriteOut_Locked((char*)buf, len); | 574 *out_len = emitter_->WriteOut_Locked((char*)buf, len); |
| 574 return 0; | 575 return 0; |
| 575 } | 576 } |
| 576 | 577 |
| 577 } // namespace nacl_io | 578 } // namespace nacl_io |
| 578 | 579 |
| 579 #endif // PROVIDES_SOCKET_API | 580 #endif // PROVIDES_SOCKET_API |
| OLD | NEW |