summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-02-19 17:45:57 -0500
committerMike Lockwood <lockwood@android.com>2010-04-28 11:33:13 -0400
commit505bd6e5fcc576eb3bea87ac86db8aeed86d9a0d (patch)
treeb51483a1ef828699676c36743ccfdcfda27077a3
parent805c4a70300ed918853eec2f67e7b45919e48e10 (diff)
downloadsystem_core-505bd6e5fcc576eb3bea87ac86db8aeed86d9a0d.zip
system_core-505bd6e5fcc576eb3bea87ac86db8aeed86d9a0d.tar.gz
system_core-505bd6e5fcc576eb3bea87ac86db8aeed86d9a0d.tar.bz2
adb: Add five second timeout for USB writes on Linux host.
This helps us recover when things go wrong during automated testing. Change-Id: I006dbfaff7f70d51398ff12fbddcaee751453b78 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--adb/adb.h2
-rw-r--r--adb/usb_linux.c11
2 files changed, 10 insertions, 3 deletions
diff --git a/adb/adb.h b/adb/adb.h
index a148019..aaf8a28 100644
--- a/adb/adb.h
+++ b/adb/adb.h
@@ -33,7 +33,7 @@
#define ADB_VERSION_MAJOR 1 // Used for help/version information
#define ADB_VERSION_MINOR 0 // Used for help/version information
-#define ADB_SERVER_VERSION 25 // Increment this when we want to force users to start a new adb server
+#define ADB_SERVER_VERSION 26 // Increment this when we want to force users to start a new adb server
typedef struct amessage amessage;
typedef struct apacket apacket;
diff --git a/adb/usb_linux.c b/adb/usb_linux.c
index 66ee317..bb86813 100644
--- a/adb/usb_linux.c
+++ b/adb/usb_linux.c
@@ -21,6 +21,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
+#include <sys/time.h>
#include <dirent.h>
#include <fcntl.h>
#include <errno.h>
@@ -287,6 +288,8 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
{
struct usbdevfs_urb *urb = &h->urb_out;
int res;
+ struct timeval tv;
+ struct timespec ts;
memset(urb, 0, sizeof(*urb));
urb->type = USBDEVFS_URB_TYPE_BULK;
@@ -313,8 +316,12 @@ static int usb_bulk_write(usb_handle *h, const void *data, int len)
res = -1;
h->urb_out_busy = 1;
for(;;) {
- adb_cond_wait(&h->notify, &h->lock);
- if(h->dead) {
+ /* time out after five seconds */
+ gettimeofday(&tv, NULL);
+ ts.tv_sec = tv.tv_sec + 5;
+ ts.tv_nsec = tv.tv_usec * 1000L;
+ res = pthread_cond_timedwait(&h->notify, &h->lock, &ts);
+ if(res < 0 || h->dead) {
break;
}
if(h->urb_out_busy == 0) {