summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorVinit Deshapnde <vinitd@google.com>2013-11-12 15:36:37 -0800
committerVinit Deshapnde <vinitd@google.com>2013-11-12 15:36:37 -0800
commit4038724a536c990859866489195add7ed537006b (patch)
treebf1d2b0aa115f2a182e821294f9423bc5bb4f332 /services
parent105b9b05041ea6f1109d961d548f3dde2bd69501 (diff)
downloadframeworks_base-4038724a536c990859866489195add7ed537006b.zip
frameworks_base-4038724a536c990859866489195add7ed537006b.tar.gz
frameworks_base-4038724a536c990859866489195add7ed537006b.tar.bz2
Get rid of a race in NsdService in stopResolveService and getAddrInfo
Both requests are made using same id; and there is a chance that stopResolve() is not fully completed when getAddrInfo() is issued. That results getAddrInfo() failure, because both are using same requestId. This change fixes this problem by creating a new unique id to call getAddrInfo() with. Bug: 11597153 Change-Id: I56bd78740e8a40bd31c52705dc797486aff53a50
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/NsdService.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/services/java/com/android/server/NsdService.java b/services/java/com/android/server/NsdService.java
index e0f415b..16d2468 100644
--- a/services/java/com/android/server/NsdService.java
+++ b/services/java/com/android/server/NsdService.java
@@ -483,10 +483,14 @@ public class NsdService extends INsdManager.Stub {
clientInfo.mResolvedService.setPort(Integer.parseInt(cooked[4]));
stopResolveService(id);
- if (!getAddrInfo(id, cooked[3])) {
+ removeRequestMap(clientId, id, clientInfo);
+
+ int id2 = getUniqueId();
+ if (getAddrInfo(id2, cooked[3])) {
+ storeRequestMap(clientId, id2, clientInfo);
+ } else {
clientInfo.mChannel.sendMessage(NsdManager.RESOLVE_SERVICE_FAILED,
NsdManager.FAILURE_INTERNAL_ERROR, clientId);
- removeRequestMap(clientId, id, clientInfo);
clientInfo.mResolvedService = null;
}
break;