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

Unified Diff: runtime/bin/socket_android.cc

Issue 17842003: Avoid picking port 65535 for ServerSockets, when any is requested. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 months 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 | runtime/bin/socket_linux.cc » ('j') | runtime/bin/socket_macos.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_android.cc
diff --git a/runtime/bin/socket_android.cc b/runtime/bin/socket_android.cc
index d83789297b2af6c7a75870e990c498aa19e7c0b7..748f33ecbe0ec59d74cd66e7a4aecffea251a112 100644
--- a/runtime/bin/socket_android.cc
+++ b/runtime/bin/socket_android.cc
@@ -323,6 +323,17 @@ intptr_t ServerSocket::CreateBindListen(RawAddr addr,
return -1;
}
+ // Test for invalid socket port 65535 (some browsers disallow it).
+ if (port == 0 && Socket::GetPort(fd) == 65535) {
+ // Don't close fd until we have created new. By doing that we ensure another
+ // port.
+ intptr_t new_fd = CreateBindListen(addr, 0, backlog, v6_only);
+ int err = errno;
+ TEMP_FAILURE_RETRY(close(fd));
+ errno = err;
+ return new_fd;
+ }
+
if (TEMP_FAILURE_RETRY(listen(fd, backlog > 0 ? backlog : SOMAXCONN)) != 0) {
TEMP_FAILURE_RETRY(close(fd));
return -1;
« no previous file with comments | « no previous file | runtime/bin/socket_linux.cc » ('j') | runtime/bin/socket_macos.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698