Merge "ugly, temporary, workaroung for a problem where a binder thread spins forever" into jb-mr1-dev
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp
index 6e83faa..03c1082 100644
--- a/libs/binder/IPCThreadState.cpp
+++ b/libs/binder/IPCThreadState.cpp
@@ -482,6 +482,18 @@
         if(result == TIMED_OUT && !isMain) {
             break;
         }
+
+        // HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
+        // FIXME: we sometimes get unexplained EINVAL which causes this
+        // thread to spin forever. TEMPORARILY allow it to exit.
+        // We should probably assert on eng builds
+        if(result == -EINVAL && !isMain) {
+            ALOGE("**** THREAD %p (PID %d) ERROR (%d) LEAVING THE THREAD POOL\n",
+                (void*)pthread_self(), getpid(), result);
+            break;
+        }
+        // HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK
+
     } while (result != -ECONNREFUSED && result != -EBADF);
 
     LOG_THREADPOOL("**** THREAD %p (PID %d) IS LEAVING THE THREAD POOL err=%p\n",