From 9a21249a6c86cc37f915be7830715981c8bf691a Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 2 Feb 2012 13:07:47 -0800 Subject: [PATCH] Avoid NDC deadlock when re-arming network alert. When NDC delivers limitReached() event, NMS re-arms the alert, which makes another call back to NDC. If NDC already started processing another call, this causes deadlock. Fix this by re-arming on a handler thread. Bug: 5879848 Change-Id: I46fa78fe1f1122c5f31dd6020483e5ae89a9f39d --- .../java/com/android/server/net/NetworkStatsService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/net/NetworkStatsService.java b/services/java/com/android/server/net/NetworkStatsService.java index 7930caf847..414ed1e2ad 100644 --- a/services/java/com/android/server/net/NetworkStatsService.java +++ b/services/java/com/android/server/net/NetworkStatsService.java @@ -121,6 +121,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { private static final int MSG_PERFORM_POLL = 1; private static final int MSG_UPDATE_IFACES = 2; + private static final int MSG_REGISTER_GLOBAL_ALERT = 3; /** Flags to control detail level of poll event. */ private static final int FLAG_PERSIST_NETWORK = 0x1; @@ -600,7 +601,7 @@ public class NetworkStatsService extends INetworkStatsService.Stub { mHandler.obtainMessage(MSG_PERFORM_POLL, flags, 0).sendToTarget(); // re-arm global alert for next update - registerGlobalAlert(); + mHandler.obtainMessage(MSG_REGISTER_GLOBAL_ALERT).sendToTarget(); } } }; @@ -951,6 +952,10 @@ public class NetworkStatsService extends INetworkStatsService.Stub { updateIfaces(); return true; } + case MSG_REGISTER_GLOBAL_ALERT: { + registerGlobalAlert(); + return true; + } default: { return false; }