Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit be12b81b authored by Tetsutoki Shiozawa's avatar Tetsutoki Shiozawa Committed by Koji Fukui
Browse files

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.
e83724e2 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
parent e4e52917
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -134,21 +134,23 @@ final class NativeDaemonConnector implements Runnable, Handler.Callback, Watchdo
        mCallbackHandler = new Handler(mLooper, this);

        while (true) {
            if (isShuttingDown()) break;
            try {
                listenToSocket();
            } catch (Exception e) {
                loge("Error in NativeDaemonConnector: " + e);
                String shutdownAct = SystemProperties.get(
                        ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
                if (shutdownAct != null && shutdownAct.length() > 0) {
                    // The device is in middle of shutdown.
                    break;
                }
                if (isShuttingDown()) break;
                SystemClock.sleep(5000);
            }
        }
    }

    private static boolean isShuttingDown() {
        String shutdownAct = SystemProperties.get(
            ShutdownThread.SHUTDOWN_ACTION_PROPERTY, "");
        return shutdownAct != null && shutdownAct.length() > 0;
    }

    @Override
    public boolean handleMessage(Message msg) {
        final String event = (String) msg.obj;