Skip to content

Commit ada763c

Browse files
committed
pg_basebackup: Error handling fixes.
Thomas Ogrisegg and Fujii Masao
1 parent 81f6bbe commit ada763c

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
584584
{
585585
fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
586586
progname, filename, get_gz_error(ztarfile));
587+
disconnect_and_exit(1);
587588
}
588589
}
589590
else
@@ -597,21 +598,28 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
597598
}
598599
}
599600

600-
if (strcmp(basedir, "-") == 0)
601-
{
602601
#ifdef HAVE_LIBZ
603-
if (ztarfile)
604-
gzclose(ztarfile);
605-
#endif
602+
if (ztarfile != NULL)
603+
{
604+
if (gzclose(ztarfile) != 0)
605+
{
606+
fprintf(stderr, _("%s: could not close compressed file \"%s\": %s\n"),
607+
progname, filename, get_gz_error(ztarfile));
608+
disconnect_and_exit(1);
609+
}
606610
}
607611
else
608-
{
609-
#ifdef HAVE_LIBZ
610-
if (ztarfile != NULL)
611-
gzclose(ztarfile);
612612
#endif
613-
if (tarfile != NULL)
614-
fclose(tarfile);
613+
{
614+
if (strcmp(basedir, "-") != 0)
615+
{
616+
if (fclose(tarfile) != 0)
617+
{
618+
fprintf(stderr, _("%s: could not close file \"%s\": %s\n"),
619+
progname, filename, strerror(errno));
620+
disconnect_and_exit(1);
621+
}
622+
}
615623
}
616624

617625
break;
@@ -630,6 +638,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
630638
{
631639
fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
632640
progname, filename, get_gz_error(ztarfile));
641+
disconnect_and_exit(1);
633642
}
634643
}
635644
else

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy