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

Commit bbd27419 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Improved error handling." into nyc-dev

parents 12af7d51 1634d841
Loading
Loading
Loading
Loading
+9 −8
Original line number Original line Diff line number Diff line
@@ -80,8 +80,8 @@ int main(int argc, char *argv[]) {
    }
    }


    if (s == -1) {
    if (s == -1) {
        printf("Failed to connect to dumpstatez service: %s\n", strerror(errno));
        printf("FAIL:Failed to connect to dumpstatez service: %s\n", strerror(errno));
        return EXIT_FAILURE;
        return EXIT_SUCCESS;
    }
    }


    // Set a timeout so that if nothing is read in 10 minutes, we'll stop
    // Set a timeout so that if nothing is read in 10 minutes, we'll stop
@@ -91,7 +91,7 @@ int main(int argc, char *argv[]) {
    tv.tv_sec = 10 * 60;
    tv.tv_sec = 10 * 60;
    tv.tv_usec = 0;
    tv.tv_usec = 0;
    if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
    if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == -1) {
        printf("WARNING: Cannot set socket timeout: %s\n", strerror(errno));
        fprintf(stderr, "WARNING: Cannot set socket timeout: %s\n", strerror(errno));
    }
    }


    while (1) {
    while (1) {
@@ -105,8 +105,7 @@ int main(int argc, char *argv[]) {
            if (errno == EAGAIN) {
            if (errno == EAGAIN) {
                errno = ETIMEDOUT;
                errno = ETIMEDOUT;
            }
            }
            printf("\nBugreport read terminated abnormally (%s).\n",
            printf("FAIL:Bugreport read terminated abnormally (%s)\n", strerror(errno));
                    strerror(errno));
            break;
            break;
        }
        }


@@ -117,15 +116,17 @@ int main(int argc, char *argv[]) {
                    write(STDOUT_FILENO, buffer + bytes_read - bytes_to_send,
                    write(STDOUT_FILENO, buffer + bytes_read - bytes_to_send,
                            bytes_to_send));
                            bytes_to_send));
            if (bytes_written == -1) {
            if (bytes_written == -1) {
                printf(
                fprintf(stderr,
                        "Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
                        "Failed to write data to stdout: read %zd, trying to send %zd (%s)\n",
                        bytes_read, bytes_to_send, strerror(errno));
                        bytes_read, bytes_to_send, strerror(errno));
                return EXIT_FAILURE;
                break;
            }
            }
            bytes_to_send -= bytes_written;
            bytes_to_send -= bytes_written;
        } while (bytes_written != 0 && bytes_to_send > 0);
        } while (bytes_written != 0 && bytes_to_send > 0);
    }
    }


    close(s);
    if (close(s) == -1) {
        fprintf(stderr, "WARNING: error closing socket: %s\n", strerror(errno));
    }
    return EXIT_SUCCESS;
    return EXIT_SUCCESS;
}
}