diff options
author | Robert Haas <rhaas@postgresql.org> | 2012-03-28 12:19:22 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2012-03-28 12:19:22 -0400 |
commit | ada763cfcd0978cf95ebb0587f40a45b5cb57594 (patch) | |
tree | d41d817a6142c671ed6499d66437da7e92e62c2a | |
parent | 81f6bbe8ade8c90f23f9286ca9ca726d3e0e310f (diff) |
pg_basebackup: Error handling fixes.
Thomas Ogrisegg and Fujii Masao
-rw-r--r-- | src/bin/pg_basebackup/pg_basebackup.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index ac7a83481d0..89860852f40 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -584,6 +584,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) { fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"), progname, filename, get_gz_error(ztarfile)); + disconnect_and_exit(1); } } else @@ -597,21 +598,28 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) } } - if (strcmp(basedir, "-") == 0) - { #ifdef HAVE_LIBZ - if (ztarfile) - gzclose(ztarfile); -#endif + if (ztarfile != NULL) + { + if (gzclose(ztarfile) != 0) + { + fprintf(stderr, _("%s: could not close compressed file \"%s\": %s\n"), + progname, filename, get_gz_error(ztarfile)); + disconnect_and_exit(1); + } } else - { -#ifdef HAVE_LIBZ - if (ztarfile != NULL) - gzclose(ztarfile); #endif - if (tarfile != NULL) - fclose(tarfile); + { + if (strcmp(basedir, "-") != 0) + { + if (fclose(tarfile) != 0) + { + fprintf(stderr, _("%s: could not close file \"%s\": %s\n"), + progname, filename, strerror(errno)); + disconnect_and_exit(1); + } + } } break; @@ -630,6 +638,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum) { fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"), progname, filename, get_gz_error(ztarfile)); + disconnect_and_exit(1); } } else |