am 207c17ff: Merge "Make adb robust against EINTR"

* commit '207c17ff1f48d0db3c69628bb036a14db40b5887':
  Make adb robust against EINTR
diff --git a/adb/services.c b/adb/services.c
index 495a083..54d21a8 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -202,7 +202,7 @@
     int c;
 
     for(;;) {
-        r = read(fd, buf, 4096);
+        r = adb_read(fd, buf, 4096);
         if(r == 0) goto done;
         if(r < 0) {
             if(errno == EINTR) continue;
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 66b60cc..ee7cd49 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -275,6 +275,7 @@
 #include <netinet/in.h>
 #include <netinet/tcp.h>
 #include <string.h>
+#include <unistd.h>
 
 #define OS_PATH_SEPARATOR '/'
 #define OS_PATH_SEPARATOR_STR "/"
@@ -310,7 +311,7 @@
 {
     if ((options & O_CREAT) == 0)
     {
-        return  open(path, options);
+        return  TEMP_FAILURE_RETRY( open(path, options) );
     }
     else
     {
@@ -319,19 +320,19 @@
         va_start( args, options );
         mode = va_arg( args, int );
         va_end( args );
-        return open(path, options, mode);
+        return TEMP_FAILURE_RETRY( open( path, options, mode ) );
     }
 }
 
 static __inline__ int  adb_open_mode( const char*  pathname, int  options, int  mode )
 {
-    return open( pathname, options, mode );
+    return TEMP_FAILURE_RETRY( open( pathname, options, mode ) );
 }
 
 
 static __inline__ int  adb_open( const char*  pathname, int  options )
 {
-    int  fd = open( pathname, options );
+    int  fd = TEMP_FAILURE_RETRY( open( pathname, options ) );
     if (fd < 0)
         return -1;
     close_on_exec( fd );
@@ -357,7 +358,7 @@
 
 static __inline__  int  adb_read(int  fd, void*  buf, size_t  len)
 {
-    return read(fd, buf, len);
+    return TEMP_FAILURE_RETRY( read( fd, buf, len ) );
 }
 
 #undef   read
@@ -365,7 +366,7 @@
 
 static __inline__  int  adb_write(int  fd, const void*  buf, size_t  len)
 {
-    return write(fd, buf, len);
+    return TEMP_FAILURE_RETRY( write( fd, buf, len ) );
 }
 #undef   write
 #define  write  ___xxx_write
@@ -386,7 +387,7 @@
 
 static __inline__  int  adb_creat(const char*  path, int  mode)
 {
-    int  fd = creat(path, mode);
+    int  fd = TEMP_FAILURE_RETRY( creat( path, mode ) );
 
     if ( fd < 0 )
         return -1;
@@ -401,7 +402,7 @@
 {
     int fd;
 
-    fd = accept(serverfd, addr, addrlen);
+    fd = TEMP_FAILURE_RETRY( accept( serverfd, addr, addrlen ) );
     if (fd >= 0)
         close_on_exec(fd);