summaryrefslogtreecommitdiffstats
path: root/vm/jdwp
diff options
context:
space:
mode:
authorAndy McFadden <fadden@android.com>2009-06-03 15:53:27 -0700
committerAndy McFadden <fadden@android.com>2009-06-03 16:26:31 -0700
commit6196d15e42f317a8075f0d8b8c92b0c69736d037 (patch)
treeae572785c56db21adf0167f77d1d3118b3a410f3 /vm/jdwp
parent3361e3c0280a7c5b7e1a10c74558bca331a892a5 (diff)
downloadandroid_dalvik-6196d15e42f317a8075f0d8b8c92b0c69736d037.tar.gz
android_dalvik-6196d15e42f317a8075f0d8b8c92b0c69736d037.tar.bz2
android_dalvik-6196d15e42f317a8075f0d8b8c92b0c69736d037.zip
Retry on all ADB failures.
Change 2644 added retries when ADB went away. The VM occasionally thinks it has reconnected to adbd as it's dying, which caused a different type of failure, and the JDWP thread went off to sulk. This rearranges the failure handling some more, so that all failures are treated equally (with slight differences in logging).
Diffstat (limited to 'vm/jdwp')
-rw-r--r--vm/jdwp/JdwpAdb.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/vm/jdwp/JdwpAdb.c b/vm/jdwp/JdwpAdb.c
index 1b0714ddb..a74f9e150 100644
--- a/vm/jdwp/JdwpAdb.c
+++ b/vm/jdwp/JdwpAdb.c
@@ -134,8 +134,8 @@ static bool startup(struct JdwpState* state, const JdwpStartupParams* pParams)
* Receive a file descriptor from ADB. The fd can be used to communicate
* directly with a debugger or DDMS.
*
- * Returns the file descriptor on success, -1 on call failure. If ADB
- * went away, this closes netState->controlSock and returns -2.
+ * Returns the file descriptor on success. On failure, returns -1 and
+ * closes netState->controlSock.
*/
static int receiveClientFd(JdwpNetState* netState)
{
@@ -169,14 +169,16 @@ static int receiveClientFd(JdwpNetState* netState)
ret = recvmsg(netState->controlSock, &msg, 0);
} while (ret < 0 && errno == EINTR);
- if (ret < 0) {
- LOGE("receiving file descriptor from ADB failed (socket %d): %s\n",
- netState->controlSock, strerror(errno));
- return -1;
- } else if (ret == 0) {
+ if (ret <= 0) {
+ if (ret < 0) {
+ LOGW("receiving file descriptor from ADB failed (socket %d): %s\n",
+ netState->controlSock, strerror(errno));
+ } else {
+ LOGI("adbd disconnected\n");
+ }
close(netState->controlSock);
netState->controlSock = -1;
- return -2;
+ return -1;
}
return ((int*)CMSG_DATA(cmsg))[0];
@@ -269,14 +271,9 @@ retry:
if (netState->shuttingDown)
return false; // suppress logs and additional activity
- if (netState->clientSock == -1) {
- return false;
- } else if (netState->clientSock == -2) {
- LOGD("adbd dropped us; retrying connection\n");
- assert(netState->controlSock < 0);
+ if (netState->clientSock < 0) {
if (++retryCount > 5) {
- /* shouldn't be possible, but we check it just in case */
- LOGE("max retries exceeded\n");
+ LOGE("adb connection max retries exceeded\n");
return false;
}
goto retry;
@@ -581,10 +578,18 @@ static bool processIncoming(JdwpState* state)
if (netState->controlSock >= 0 &&
FD_ISSET(netState->controlSock, &readfds))
{
- LOGI("Ignoring second debugger -- accepting and dropping\n");
int sock = receiveClientFd(netState);
- if (sock >= 0)
+ if (sock >= 0) {
+ LOGI("Ignoring second debugger -- accepting and dropping\n");
close(sock);
+ } else {
+ assert(netState->controlSock < 0);
+ /*
+ * Remote side most likely went away, so our next read
+ * on netState->clientSock will fail and throw us out
+ * of the loop.
+ */
+ }
}
if (netState->clientSock >= 0 &&
FD_ISSET(netState->clientSock, &readfds))