aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2012-03-16 09:21:02 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2012-03-16 09:21:02 -0700
commit10bc04fd968d7f80258bf1eec665babf28e9e47d (patch)
tree30269c62a7f2d6658b6c6ebc2ad2fcf7c1d9ddb0 /android
parentfacee1d1d0c3029915f5443c788cd32b9f5b9c83 (diff)
downloadexternal_qemu-10bc04fd968d7f80258bf1eec665babf28e9e47d.zip
external_qemu-10bc04fd968d7f80258bf1eec665babf28e9e47d.tar.gz
external_qemu-10bc04fd968d7f80258bf1eec665babf28e9e47d.tar.bz2
Fixes a hack that was enabling multi-touch emulation on Mac.
The issue was that on Mac there is a bug in select() implementation, that caused select() to fail with EINVAL on condition that timeout exceeds 100000000 secods. So the real fix was to clamp timout value to that limit when select() is called on Mac. Change-Id: Icb9ead00a0060028957af1e6e22911d5e8e231c6
Diffstat (limited to 'android')
-rw-r--r--android/android-device.c71
1 files changed, 23 insertions, 48 deletions
diff --git a/android/android-device.c b/android/android-device.c
index e91185d..40ec294 100644
--- a/android/android-device.c
+++ b/android/android-device.c
@@ -597,60 +597,35 @@ _android_dev_socket_recv(AndroidDevSocket* ads, char* buf, int bufsize)
return -1;
}
- /* XXX: This is a hack that implements a blocked line read on an async
- * event socket! Redo this ASAP! */
- if (ads->type == ADS_TYPE_EVENT) {
- AndroidEventSocket* adsevent = (AndroidEventSocket*)ads;
- asyncLineReader_init(&adsevent->alr, buf, bufsize, adsevent->io);
- /* Default EOL for the line reader was '\n'. */
- asyncLineReader_setEOL(&adsevent->alr, '\0');
- AsyncStatus status = ASYNC_NEED_MORE;
-
- while (status == ASYNC_NEED_MORE) {
- status = asyncLineReader_read(&adsevent->alr);
- if (status == ASYNC_COMPLETE) {
- recvd = adsevent->alr.pos;
- break;
- } else if (status == ASYNC_ERROR) {
- if (errno == ENOMEM) {
- recvd = adsevent->alr.pos;
- } else {
- recvd = -1;
- }
- break;
- }
+ iolooper_add_read(_ads_io_looper(ads), ads->fd);
+ do {
+ int res = socket_recv(ads->fd, buf + recvd, bufsize - recvd);
+ if (res == 0) {
+ /* Disconnection. */
+ errno = ECONNRESET;
+ recvd = -1;
+ break;
}
- } else {
- iolooper_add_read(_ads_io_looper(ads), ads->fd);
- do {
- int res = socket_recv(ads->fd, buf + recvd, bufsize - recvd);
- if (res == 0) {
- /* Disconnection. */
- errno = ECONNRESET;
- recvd = -1;
- break;
+
+ if (res < 0) {
+ if (errno == EINTR) {
+ /* loop on EINTR */
+ continue;
}
- if (res < 0) {
- if (errno == EINTR) {
- /* loop on EINTR */
+ if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ res = iolooper_wait_absolute(_ads_io_looper(ads), ads->deadline);
+ if (res > 0) {
+ /* Ready to read. */
continue;
}
-
- if (errno == EWOULDBLOCK || errno == EAGAIN) {
- res = iolooper_wait_absolute(_ads_io_looper(ads), ads->deadline);
- if (res > 0) {
- /* Ready to read. */
- continue;
- }
- }
- recvd = -1;
- break;
}
- recvd += res;
- } while (recvd < bufsize);
- iolooper_del_read(_ads_io_looper(ads), ads->fd);
- }
+ recvd = -1;
+ break;
+ }
+ recvd += res;
+ } while (recvd < bufsize);
+ iolooper_del_read(_ads_io_looper(ads), ads->fd);
/* In case of an I/O failure we have to invoke failure callback. Note that we
* report I/O failures only on registered sockets. */