OSDN Git Service

Work around a dalvik JDWP/GC deadlock.
[android-x86/dalvik.git] / vm / jdwp / JdwpAdb.cpp
index 23878fe..8fb5391 100644 (file)
@@ -165,7 +165,7 @@ static int  receiveClientFd(JdwpNetState*  netState)
 
     if (ret <= 0) {
         if (ret < 0) {
-            LOGW("receiving file descriptor from ADB failed (socket %d): %s",
+            ALOGW("receiving file descriptor from ADB failed (socket %d): %s",
                  netState->controlSock, strerror(errno));
         }
         close(netState->controlSock);
@@ -201,13 +201,13 @@ retry:
 
         netState->controlSock = socket(PF_UNIX, SOCK_STREAM, 0);
         if (netState->controlSock < 0) {
-            LOGE("Could not create ADB control socket:%s",
+            ALOGE("Could not create ADB control socket:%s",
                  strerror(errno));
             return false;
         }
 
         if (pipe(netState->wakeFds) < 0) {
-            LOGE("pipe failed");
+            ALOGE("pipe failed");
             return false;
         }
 
@@ -234,7 +234,7 @@ retry:
             if (!ret) {
                 if (!socket_peer_is_trusted(netState->controlSock)) {
                     if (shutdown(netState->controlSock, SHUT_RDWR)) {
-                        LOGE("trouble shutting down socket: %s", strerror(errno));
+                        ALOGE("trouble shutting down socket: %s", strerror(errno));
                     }
                     return false;
                 }
@@ -249,7 +249,7 @@ retry:
                     break;
                 }
 
-                LOGE("Weird, can't send JDWP process pid to ADB: %s",
+                ALOGE("Weird, can't send JDWP process pid to ADB: %s",
                      strerror(errno));
                 return false;
             }
@@ -275,7 +275,7 @@ retry:
 
     if (netState->clientSock < 0) {
         if (++retryCount > 5) {
-            LOGE("adb connection max retries exceeded");
+            ALOGE("adb connection max retries exceeded");
             return false;
         }
         goto retry;
@@ -345,7 +345,7 @@ static void adbStateShutdown(struct JdwpNetState* netState)
 
     if (netState->wakeFds[1] >= 0) {
         ALOGV("+++ writing to wakePipe");
-        write(netState->wakeFds[1], "", 1);
+        TEMP_FAILURE_RETRY(write(netState->wakeFds[1], "", 1));
     }
 }
 
@@ -463,12 +463,12 @@ static bool handlePacket(JdwpState* state)
             ssize_t cc = netState->writePacket(pReply);
 
             if (cc != (ssize_t) expandBufGetLength(pReply)) {
-                LOGE("Failed sending reply to debugger: %s", strerror(errno));
+                ALOGE("Failed sending reply to debugger: %s", strerror(errno));
                 expandBufFree(pReply);
                 return false;
             }
         } else {
-            LOGW("No reply created for set=%d cmd=%d", cmdSet, cmd);
+            ALOGW("No reply created for set=%d cmd=%d", cmdSet, cmd);
         }
         expandBufFree(pReply);
     } else {
@@ -534,7 +534,7 @@ static bool processIncoming(JdwpState* state)
                 if (maxfd < fd)
                     maxfd = fd;
             } else {
-                LOGI("NOTE: entering select w/o wakepipe");
+                ALOGI("NOTE: entering select w/o wakepipe");
             }
 
             if (maxfd < 0) {
@@ -558,14 +558,14 @@ static bool processIncoming(JdwpState* state)
             if (selCount < 0) {
                 if (errno == EINTR)
                     continue;
-                LOGE("select failed: %s", strerror(errno));
+                ALOGE("select failed: %s", strerror(errno));
                 goto fail;
             }
 
             if (netState->wakeFds[0] >= 0 &&
                 FD_ISSET(netState->wakeFds[0], &readfds))
             {
-                LOGD("Got wake-up signal, bailing out of select");
+                ALOGD("Got wake-up signal, bailing out of select");
                 goto fail;
             }
             if (netState->controlSock >= 0 &&
@@ -573,7 +573,7 @@ static bool processIncoming(JdwpState* state)
             {
                 int  sock = receiveClientFd(netState);
                 if (sock >= 0) {
-                    LOGI("Ignoring second debugger -- accepting and dropping");
+                    ALOGI("Ignoring second debugger -- accepting and dropping");
                     close(sock);
                 } else {
                     assert(netState->controlSock < 0);
@@ -594,7 +594,7 @@ static bool processIncoming(JdwpState* state)
                     /* read failed */
                     if (errno != EINTR)
                         goto fail;
-                    LOGD("+++ EINTR hit");
+                    ALOGD("+++ EINTR hit");
                     return true;
                 } else if (readCount == 0) {
                     /* EOF hit -- far end went away */
@@ -624,15 +624,15 @@ static bool processIncoming(JdwpState* state)
         if (memcmp(netState->inputBuffer,
                 kMagicHandshake, kMagicHandshakeLen) != 0)
         {
-            LOGE("ERROR: bad handshake '%.14s'", netState->inputBuffer);
+            ALOGE("ERROR: bad handshake '%.14s'", netState->inputBuffer);
             goto fail;
         }
 
         errno = 0;
-        cc = write(netState->clientSock, netState->inputBuffer,
-                kMagicHandshakeLen);
+        cc = TEMP_FAILURE_RETRY(write(netState->clientSock, netState->inputBuffer,
+                                      kMagicHandshakeLen));
         if (cc != kMagicHandshakeLen) {
-            LOGE("Failed writing handshake bytes: %s (%d of %d)",
+            ALOGE("Failed writing handshake bytes: %s (%d of %d)",
                 strerror(errno), cc, (int) kMagicHandshakeLen);
             goto fail;
         }
@@ -676,7 +676,7 @@ static bool sendRequest(JdwpState* state, ExpandBuf* pReq)
     ssize_t cc = netState->writePacket(pReq);
 
     if (cc != (ssize_t) expandBufGetLength(pReq)) {
-        LOGE("Failed sending req to debugger: %s (%d of %d)",
+        ALOGE("Failed sending req to debugger: %s (%d of %d)",
             strerror(errno), (int) cc, (int) expandBufGetLength(pReq));
         return false;
     }
@@ -711,7 +711,7 @@ static bool sendBufferedRequest(JdwpState* state, const struct iovec* iov,
     ssize_t actual = netState->writeBufferedPacket(iov, iovcnt);
 
     if ((size_t)actual != expected) {
-        LOGE("Failed sending b-req to debugger: %s (%d of %zu)",
+        ALOGE("Failed sending b-req to debugger: %s (%d of %zu)",
             strerror(errno), (int) actual, expected);
         return false;
     }