Definitely abort reconnecting to native daemon during shutdown

Symptom:
System_server crashed due to unsolved "netd" service.

Root cause:
My previous patch was not enough for avoiding this crash.
a00d4b0 Abort connecting to native daemon during shutdown

listenToSocket loop can be finished without throwing exception.

Solution:
It's better to test shutdown condition before reconnection even
though listenToSocket is finished without exception.

Bug: 68742327
Change-Id: Ifdfe43d52bef891f55bd7b07cc1aa0fa248a6030
This commit is contained in:
Tetsutoki Shiozawa
2017-10-27 14:03:00 +09:00
committed by Koji Fukui
parent 8469cd614d
commit 47c245b6e9

View File

@@ -134,21 +134,23 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
mCallbackHandler = new Handler(mLooper, this); mCallbackHandler = new Handler(mLooper, this);
while (true) { while (true) {
if (isShuttingDown()) break;
try { try {
listenToSocket(); listenToSocket();
} catch (Exception e) { } catch (Exception e) {
loge("Error in NativeDaemonConnector: " + e); loge("Error in NativeDaemonConnector: " + e);
String shutdownAct = SystemProperties.get( if (isShuttingDown()) break;
ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
if (shutdownAct != null && shutdownAct.length() > 0) {
// The device is in middle of shutdown.
break;
}
SystemClock.sleep(5000); SystemClock.sleep(5000);
} }
} }
} }
private static boolean isShuttingDown() {
String shutdownAct = SystemProperties.get(
ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
return shutdownAct != null && shutdownAct.length() > 0;
}
@Override @Override
public boolean handleMessage(Message msg) { public boolean handleMessage(Message msg) {
final String event = (String) msg.obj; final String event = (String) msg.obj;