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

Commit 3a92b703 authored by Felipe Leme's avatar Felipe Leme Committed by Android (Google) Code Review
Browse files

Merge "bugreportz: don't write last line when it times out."

parents 6c558b86 64e1f5b1
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ int bugreportz(int s, bool show_progress) {
                errno = ETIMEDOUT;
            }
            printf("FAIL:Bugreport read terminated abnormally (%s)\n", strerror(errno));
            break;
            return EXIT_FAILURE;
        }

        // Writes line by line.
@@ -71,8 +71,5 @@ int bugreportz(int s, bool show_progress) {
    // Process final line, in case it didn't finish with newline
    write_line(line, show_progress);

    if (close(s) == -1) {
        fprintf(stderr, "WARNING: error closing socket: %s\n", strerror(errno));
    }
    return EXIT_SUCCESS;
}
+1 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#define BUGREPORTZ_H

// Calls dumpstate using the given socket and output its result to stdout.
// Ownership of the socket is not transferred.
int bugreportz(int s, bool show_progress);

#endif  // BUGREPORTZ_H
+11 −3
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {

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

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

    bugreportz(s, show_progress);
    int ret = bugreportz(s, show_progress);

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