Snap for 4415813 from 7ff639c0ed00f1d89d315cd2aaeba1faa2d06c66 to pi-release

Change-Id: I1e7810a02b3e23992bf8238d768ddb5dee208112
This commit is contained in:
android-build-team Robot
2017-10-25 08:09:33 +00:00

View File

@@ -754,7 +754,7 @@ public class IpSecService extends IIpSecService.Stub {
* and re-binding, during which the system could *technically* hand that port out to someone * and re-binding, during which the system could *technically* hand that port out to someone
* else. * else.
*/ */
private void bindToRandomPort(FileDescriptor sockFd) throws IOException { private int bindToRandomPort(FileDescriptor sockFd) throws IOException {
for (int i = MAX_PORT_BIND_ATTEMPTS; i > 0; i--) { for (int i = MAX_PORT_BIND_ATTEMPTS; i > 0; i--) {
try { try {
FileDescriptor probeSocket = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); FileDescriptor probeSocket = Os.socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
@@ -763,7 +763,7 @@ public class IpSecService extends IIpSecService.Stub {
Os.close(probeSocket); Os.close(probeSocket);
Log.v(TAG, "Binding to port " + port); Log.v(TAG, "Binding to port " + port);
Os.bind(sockFd, INADDR_ANY, port); Os.bind(sockFd, INADDR_ANY, port);
return; return port;
} catch (ErrnoException e) { } catch (ErrnoException e) {
// Someone miraculously claimed the port just after we closed probeSocket. // Someone miraculously claimed the port just after we closed probeSocket.
if (e.errno == OsConstants.EADDRINUSE) { if (e.errno == OsConstants.EADDRINUSE) {
@@ -803,7 +803,7 @@ public class IpSecService extends IIpSecService.Stub {
Log.v(TAG, "Binding to port " + port); Log.v(TAG, "Binding to port " + port);
Os.bind(sockFd, INADDR_ANY, port); Os.bind(sockFd, INADDR_ANY, port);
} else { } else {
bindToRandomPort(sockFd); port = bindToRandomPort(sockFd);
} }
// This code is common to both the unspecified and specified port cases // This code is common to both the unspecified and specified port cases
Os.setsockoptInt( Os.setsockoptInt(