From: Paul Jensen Date: Thu, 17 Apr 2014 19:02:32 +0000 (-0400) Subject: Fix for DNS resolutions when there is no default network set yet. X-Git-Tag: android-x86-7.1-r1~209^2~5^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=dac2ca3088bc2dfe7ff0afa19e701baeae466f96;p=android-x86%2Fsystem-netd.git Fix for DNS resolutions when there is no default network set yet. We need to determine the actual netId to use prior to comparing it against the default netId. Also initialize the default network variable. bug:13877665 Change-Id: I24c05eb006e2c93d5e0a9b94fee4da408089d2b8 --- diff --git a/DnsProxyListener.cpp b/DnsProxyListener.cpp index 9b5c283..b76586b 100644 --- a/DnsProxyListener.cpp +++ b/DnsProxyListener.cpp @@ -192,6 +192,8 @@ int DnsProxyListener::GetAddrInfoCmd::runCommand(SocketClient *cli, pid_t pid = cli->getPid(); uid_t uid = cli->getUid(); + netId = mNetCtrl->getNetwork(uid, netId, pid, true); + if (ai_flags != -1 || ai_family != -1 || ai_socktype != -1 || ai_protocol != -1) { hints = (struct addrinfo*) calloc(1, sizeof(struct addrinfo)); @@ -214,8 +216,6 @@ int DnsProxyListener::GetAddrInfoCmd::runCommand(SocketClient *cli, netId, pid, uid); } - netId = mNetCtrl->getNetwork(uid, netId, pid, true); - cli->incRef(); DnsProxyListener::GetAddrInfoHandler* handler = new DnsProxyListener::GetAddrInfoHandler(cli, name, service, hints, netId); diff --git a/NetworkController.cpp b/NetworkController.cpp index a1f1535..2285b22 100644 --- a/NetworkController.cpp +++ b/NetworkController.cpp @@ -22,7 +22,9 @@ #include "NetworkController.h" // Mark 1 is reserved for SecondaryTableController::PROTECT_MARK. -NetworkController::NetworkController() : mNextFreeNetId(10) {} +NetworkController::NetworkController() + : mDefaultNetId(NETID_UNSET), + mNextFreeNetId(10) {} void NetworkController::clearNetworkPreference() { android::RWLock::AutoWLock lock(mRWLock);