From 201a6b569b3820047bfe6dc22b793e646dd7eec2 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Tue, 2 Jun 2009 14:15:22 -0700 Subject: [PATCH] Added an explicit "shutting down" flag. Change 2644 made the JdwpAdb stuff retry when the remote side went away. Unfortunately this also made it retry when the VM wanted to shut down. Since the JDWP thread is a non-daemon thread, this causes the VM to stall forever. This adds an explict flag to allow us to drop out of the retry loop. --- vm/jdwp/JdwpAdb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/vm/jdwp/JdwpAdb.c b/vm/jdwp/JdwpAdb.c index ed22af9fd..1b0714ddb 100644 --- a/vm/jdwp/JdwpAdb.c +++ b/vm/jdwp/JdwpAdb.c @@ -49,6 +49,7 @@ struct JdwpNetState { int controlSock; int clientSock; bool awaitingHandshake; + bool shuttingDown; int wakeFds[2]; int inputCount; @@ -196,8 +197,10 @@ static bool acceptConnection(struct JdwpState* state) /* first, ensure that we get a connection to the ADB daemon */ retry: - if (netState->controlSock < 0) - { + if (netState->shuttingDown) + return false; + + if (netState->controlSock < 0) { int sleep_ms = 500; const int sleep_max_ms = 2*1000; char buff[5]; @@ -263,6 +266,9 @@ retry: LOGV("trying to receive file descriptor from ADB\n"); /* now we can receive a client file descriptor */ netState->clientSock = receiveClientFd(netState); + if (netState->shuttingDown) + return false; // suppress logs and additional activity + if (netState->clientSock == -1) { return false; } else if (netState->clientSock == -2) { @@ -324,6 +330,8 @@ static void adbStateShutdown(struct JdwpNetState* netState) if (netState == NULL) return; + netState->shuttingDown = true; + clientSock = netState->clientSock; if (clientSock >= 0) { shutdown(clientSock, SHUT_RDWR); -- 2.11.0