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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc

Issue 63573006: [NaCl SDK] nacl_io: Auto-bind UDP socket on first sendto(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: getsockname stuff Created 7 years, 1 month 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
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/mount_node_udp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698