| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 <errno.h> | 8 #include <errno.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 455 } |
| 456 | 456 |
| 457 return ENOTCONN; | 457 return ENOTCONN; |
| 458 } | 458 } |
| 459 | 459 |
| 460 Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) { | 460 Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) { |
| 461 if (NULL == addr || NULL == len) | 461 if (NULL == addr || NULL == len) |
| 462 return EFAULT; | 462 return EFAULT; |
| 463 | 463 |
| 464 AUTO_LOCK(node_lock_); | 464 AUTO_LOCK(node_lock_); |
| 465 if (local_addr_ != 0) { | 465 if (local_addr_ == 0) { |
| 466 *len = ResourceToSockAddr(local_addr_, *len, addr); | 466 // getsockname succeeds even if the socket is not bound. In this case, |
| 467 // just return address 0, port 0. |
| 468 memset(addr, 0, *len); |
| 467 return 0; | 469 return 0; |
| 468 } | 470 } |
| 469 | 471 |
| 470 return ENOTCONN; | 472 *len = ResourceToSockAddr(local_addr_, *len, addr); |
| 473 return 0; |
| 471 } | 474 } |
| 472 | 475 |
| 473 } // namespace nacl_io | 476 } // namespace nacl_io |
| 474 | 477 |
| 475 #endif // PROVIDES_SOCKET_API | 478 #endif // PROVIDES_SOCKET_API |
| OLD | NEW |