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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
index 1d8ac375d88004d53f1f5b9ad38593e155949c09..f5c20c1b0a5092cb1d370db4f7415a16bb9b892f 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node_socket.cc
@@ -462,12 +462,15 @@ Error MountNodeSocket::GetSockName(struct sockaddr* addr, socklen_t* len) {
return EFAULT;
AUTO_LOCK(node_lock_);
- if (local_addr_ != 0) {
- *len = ResourceToSockAddr(local_addr_, *len, addr);
+ if (local_addr_ == 0) {
+ // getsockname succeeds even if the socket is not bound. In this case,
+ // just return address 0, port 0.
+ memset(addr, 0, *len);
return 0;
}
- return ENOTCONN;
+ *len = ResourceToSockAddr(local_addr_, *len, addr);
+ return 0;
}
} // namespace nacl_io
« 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