* commit '12d762e17694c0137aa7570b4b71536e59643bb0': EINTR is handled by adb_read/unix_read and friends.
This commit is contained in:
commit
e4baae6d06
6 changed files with 23 additions and 56 deletions
|
|
@ -284,10 +284,7 @@ static void read_status_line(int fd, char* buf, size_t count)
|
||||||
count--;
|
count--;
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
int len = adb_read(fd, buf, count);
|
int len = adb_read(fd, buf, count);
|
||||||
if (len == 0) {
|
if (len <= 0) {
|
||||||
break;
|
|
||||||
} else if (len < 0) {
|
|
||||||
if (errno == EINTR) continue;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -340,11 +337,7 @@ static void copy_to_file(int inFd, int outFd) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
if (errno == EINTR) {
|
D("copy_to_file(): read failed: %s\n", strerror(errno));
|
||||||
D("copy_to_file() : EINTR, retrying\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
D("copy_to_file() : error %d\n", errno);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (outFd == STDOUT_FILENO) {
|
if (outFd == STDOUT_FILENO) {
|
||||||
|
|
@ -394,12 +387,8 @@ static void *stdin_read_thread(void *x)
|
||||||
D("stdin_read_thread(): pre unix_read(fdi=%d,...)\n", fdi);
|
D("stdin_read_thread(): pre unix_read(fdi=%d,...)\n", fdi);
|
||||||
r = unix_read(fdi, buf, 1024);
|
r = unix_read(fdi, buf, 1024);
|
||||||
D("stdin_read_thread(): post unix_read(fdi=%d,...)\n", fdi);
|
D("stdin_read_thread(): post unix_read(fdi=%d,...)\n", fdi);
|
||||||
if(r == 0) break;
|
if (r <= 0) break;
|
||||||
if(r < 0) {
|
for (n = 0; n < r; n++){
|
||||||
if(errno == EINTR) continue;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for(n = 0; n < r; n++){
|
|
||||||
switch(buf[n]) {
|
switch(buf[n]) {
|
||||||
case '\n':
|
case '\n':
|
||||||
state = 1;
|
state = 1;
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ static void fdevent_process()
|
||||||
|
|
||||||
n = epoll_wait(epoll_fd, events, 256, -1);
|
n = epoll_wait(epoll_fd, events, 256, -1);
|
||||||
|
|
||||||
if(n < 0) {
|
if (n < 0) {
|
||||||
if(errno == EINTR) return;
|
if (errno == EINTR) return;
|
||||||
perror("epoll_wait");
|
perror("epoll_wait");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,13 +203,8 @@ static int write_data_file(SyncConnection& sc, const char* path, syncsendbuf* sb
|
||||||
sbuf->id = ID_DATA;
|
sbuf->id = ID_DATA;
|
||||||
while (true) {
|
while (true) {
|
||||||
int ret = adb_read(lfd, sbuf->data, sc.max);
|
int ret = adb_read(lfd, sbuf->data, sc.max);
|
||||||
if (!ret)
|
if (ret <= 0) {
|
||||||
break;
|
if (ret < 0) fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno));
|
||||||
|
|
||||||
if (ret < 0) {
|
|
||||||
if(errno == EINTR)
|
|
||||||
continue;
|
|
||||||
fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -325,7 +325,6 @@ static bool do_recv(int s, const char* path, std::vector<char>& buffer) {
|
||||||
int r = adb_read(fd, &buffer[0], buffer.size());
|
int r = adb_read(fd, &buffer[0], buffer.size());
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
if (r == 0) break;
|
if (r == 0) break;
|
||||||
if (errno == EINTR) continue;
|
|
||||||
SendSyncFailErrno(s, "read failed");
|
SendSyncFailErrno(s, "read failed");
|
||||||
adb_close(fd);
|
adb_close(fd);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -140,8 +140,7 @@ read_packet(int fd, const char* name, apacket** ppacket)
|
||||||
len -= r;
|
len -= r;
|
||||||
p += r;
|
p += r;
|
||||||
} else {
|
} else {
|
||||||
D("%s: read_packet (fd=%d), error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno));
|
D("%s: read_packet (fd=%d), error ret=%d: %s\n", name, fd, r, strerror(errno));
|
||||||
if((r < 0) && (errno == EINTR)) continue;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -171,8 +170,7 @@ write_packet(int fd, const char* name, apacket** ppacket)
|
||||||
len -= r;
|
len -= r;
|
||||||
p += r;
|
p += r;
|
||||||
} else {
|
} else {
|
||||||
D("%s: write_packet (fd=%d) error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno));
|
D("%s: write_packet (fd=%d) error ret=%d: %s\n", name, fd, r, strerror(errno));
|
||||||
if((r < 0) && (errno == EINTR)) continue;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -489,9 +487,7 @@ transport_read_action(int fd, struct tmsg* m)
|
||||||
len -= r;
|
len -= r;
|
||||||
p += r;
|
p += r;
|
||||||
} else {
|
} else {
|
||||||
if((r < 0) && (errno == EINTR)) continue;
|
D("transport_read_action: on fd %d: %s\n", fd, strerror(errno));
|
||||||
D("transport_read_action: on fd %d, error %d: %s\n",
|
|
||||||
fd, errno, strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -511,9 +507,7 @@ transport_write_action(int fd, struct tmsg* m)
|
||||||
len -= r;
|
len -= r;
|
||||||
p += r;
|
p += r;
|
||||||
} else {
|
} else {
|
||||||
if((r < 0) && (errno == EINTR)) continue;
|
D("transport_write_action: on fd %d: %s\n", fd, strerror(errno));
|
||||||
D("transport_write_action: on fd %d, error %d: %s\n",
|
|
||||||
fd, errno, strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -431,17 +431,12 @@ static void *usb_ffs_open_thread(void *x)
|
||||||
static int bulk_write(int bulk_in, const uint8_t* buf, size_t length)
|
static int bulk_write(int bulk_in, const uint8_t* buf, size_t length)
|
||||||
{
|
{
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
int ret;
|
|
||||||
|
|
||||||
do {
|
while (count < length) {
|
||||||
ret = adb_write(bulk_in, buf + count, length - count);
|
int ret = adb_write(bulk_in, buf + count, length - count);
|
||||||
if (ret < 0) {
|
if (ret < 0) return -1;
|
||||||
if (errno != EINTR)
|
count += ret;
|
||||||
return ret;
|
}
|
||||||
} else {
|
|
||||||
count += ret;
|
|
||||||
}
|
|
||||||
} while (count < length);
|
|
||||||
|
|
||||||
D("[ bulk_write done fd=%d ]\n", bulk_in);
|
D("[ bulk_write done fd=%d ]\n", bulk_in);
|
||||||
return count;
|
return count;
|
||||||
|
|
@ -462,20 +457,15 @@ static int usb_ffs_write(usb_handle* h, const void* data, int len)
|
||||||
static int bulk_read(int bulk_out, uint8_t* buf, size_t length)
|
static int bulk_read(int bulk_out, uint8_t* buf, size_t length)
|
||||||
{
|
{
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
int ret;
|
|
||||||
|
|
||||||
do {
|
while (count < length) {
|
||||||
ret = adb_read(bulk_out, buf + count, length - count);
|
int ret = adb_read(bulk_out, buf + count, length - count);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno != EINTR) {
|
D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n", bulk_out, length, count);
|
||||||
D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n",
|
return -1;
|
||||||
bulk_out, length, count);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
count += ret;
|
|
||||||
}
|
}
|
||||||
} while (count < length);
|
count += ret;
|
||||||
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue