Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e8e272c5 authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "EINTR is handled by adb_read/unix_read and friends."

parents a0f02fa9 8fcd8bc0
Loading
Loading
Loading
Loading
+4 −15
Original line number Diff line number Diff line
@@ -276,10 +276,7 @@ static void read_status_line(int fd, char* buf, size_t count)
    count--;
    while (count > 0) {
        int len = adb_read(fd, buf, count);
        if (len == 0) {
            break;
        } else if (len < 0) {
            if (errno == EINTR) continue;
        if (len <= 0) {
            break;
        }

@@ -332,11 +329,7 @@ static void copy_to_file(int inFd, int outFd) {
            break;
        }
        if (len < 0) {
            if (errno == EINTR) {
                D("copy_to_file() : EINTR, retrying\n");
                continue;
            }
            D("copy_to_file() : error %d\n", errno);
            D("copy_to_file(): read failed: %s\n", strerror(errno));
            break;
        }
        if (outFd == STDOUT_FILENO) {
@@ -386,11 +379,7 @@ static void *stdin_read_thread(void *x)
        D("stdin_read_thread(): pre unix_read(fdi=%d,...)\n", fdi);
        r = unix_read(fdi, buf, 1024);
        D("stdin_read_thread(): post unix_read(fdi=%d,...)\n", fdi);
        if(r == 0) break;
        if(r < 0) {
            if(errno == EINTR) continue;
            break;
        }
        if (r <= 0) break;
        for (n = 0; n < r; n++){
            switch(buf[n]) {
            case '\n':
+2 −7
Original line number Diff line number Diff line
@@ -203,13 +203,8 @@ static int write_data_file(SyncConnection& sc, const char* path, syncsendbuf* sb
    sbuf->id = ID_DATA;
    while (true) {
        int ret = adb_read(lfd, sbuf->data, sc.max);
        if (!ret)
            break;

        if (ret < 0) {
            if(errno == EINTR)
                continue;
            fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno));
        if (ret <= 0) {
            if (ret < 0) fprintf(stderr, "cannot read '%s': %s\n", path, strerror(errno));
            break;
        }

+0 −1
Original line number Diff line number Diff line
@@ -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());
        if (r <= 0) {
            if (r == 0) break;
            if (errno == EINTR) continue;
            SendSyncFailErrno(s, "read failed");
            adb_close(fd);
            return false;
+4 −10
Original line number Diff line number Diff line
@@ -140,8 +140,7 @@ read_packet(int fd, const char* name, apacket** ppacket)
            len -= r;
            p += r;
        } else {
            D("%s: read_packet (fd=%d), error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno));
            if((r < 0) && (errno == EINTR)) continue;
            D("%s: read_packet (fd=%d), error ret=%d: %s\n", name, fd, r, strerror(errno));
            return -1;
        }
    }
@@ -171,8 +170,7 @@ write_packet(int fd, const char* name, apacket** ppacket)
            len -= r;
            p += r;
        } else {
            D("%s: write_packet (fd=%d) error ret=%d errno=%d: %s\n", name, fd, r, errno, strerror(errno));
            if((r < 0) && (errno == EINTR)) continue;
            D("%s: write_packet (fd=%d) error ret=%d: %s\n", name, fd, r, strerror(errno));
            return -1;
        }
    }
@@ -489,9 +487,7 @@ transport_read_action(int fd, struct tmsg* m)
            len -= r;
            p   += r;
        } else {
            if((r < 0) && (errno == EINTR)) continue;
            D("transport_read_action: on fd %d, error %d: %s\n",
              fd, errno, strerror(errno));
            D("transport_read_action: on fd %d: %s\n", fd, strerror(errno));
            return -1;
        }
    }
@@ -511,9 +507,7 @@ transport_write_action(int fd, struct tmsg* m)
            len -= r;
            p   += r;
        } else {
            if((r < 0) && (errno == EINTR)) continue;
            D("transport_write_action: on fd %d, error %d: %s\n",
              fd, errno, strerror(errno));
            D("transport_write_action: on fd %d: %s\n", fd, strerror(errno));
            return -1;
        }
    }
+11 −21
Original line number Diff line number Diff line
@@ -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)
{
    size_t count = 0;
    int ret;

    do {
        ret = adb_write(bulk_in, buf + count, length - count);
        if (ret < 0) {
            if (errno != EINTR)
                return ret;
        } else {
    while (count < length) {
        int ret = adb_write(bulk_in, buf + count, length - count);
        if (ret < 0) return -1;
        count += ret;
    }
    } while (count < length);

    D("[ bulk_write done fd=%d ]\n", bulk_in);
    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)
{
    size_t count = 0;
    int ret;

    do {
        ret = adb_read(bulk_out, buf + count, length - count);
    while (count < length) {
        int ret = adb_read(bulk_out, buf + count, length - count);
        if (ret < 0) {
            if (errno != EINTR) {
                D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n",
                                           bulk_out, length, count);
                return ret;
            D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n", bulk_out, length, count);
            return -1;
        }
        } else {
        count += ret;
    }
    } while (count < length);

    return count;
}
+2 −2

File changed.

Contains only whitespace changes.

Loading