aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-03-28 12:19:22 -0400
committerRobert Haas <rhaas@postgresql.org>2012-03-28 12:21:23 -0400
commit4d278b785e22ff8d56ac86d5ed1871e096b2ea80 (patch)
tree8a4e4d0c9e99e260d829934620b165006bc25bbe /src
parent9f0a01707607e476ac3a89854777cdba76e0ff37 (diff)
downloadpostgresql-4d278b785e22ff8d56ac86d5ed1871e096b2ea80.tar.gz
postgresql-4d278b785e22ff8d56ac86d5ed1871e096b2ea80.zip
pg_basebackup: Error handling fixes.
Thomas Ogrisegg and Fujii Masao
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_basebackup/pg_basebackup.c31
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 25c0a7893ac..e9fb2cc08dc 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -410,6 +410,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
@@ -423,21 +424,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;
@@ -456,6 +464,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