Re: PATCH: pg_basebackup (missing exit on error)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Thomas Ogrisegg <tom-nic(at)patches(dot)fnord(dot)at>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: PATCH: pg_basebackup (missing exit on error)
Date: 2012-03-28 12:40:15
Message-ID: CA+TgmoZTVdHQVS3HksoOVmAY44C49mxv+K166vWgZrJ0Gavyjg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 27, 2012 at 7:13 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> Attached patch removes the fflush() part, changes the log message and removes
> the check of tarfile, as above.

With this patch applied, we end up with:

if (strcmp(basedir, "-") == 0)
{
#ifdef HAVE_LIBZ
if (ztarfile != NULL)
gzclose(ztarfile);
#endif
}
else
{
#ifdef HAVE_LIBZ
if (ztarfile != NULL)
gzclose(ztarfile);
else
#endif
{
if (fclose(tarfile) != 0)
{
fprintf(stderr, _("%s: could not close file
\"%s\": %s\n"),
progname, filename, strerror (errno));
disconnect_and_exit(1);
}
}
}

I think it would make sense to rearrange that so that we don't have
two tests for ztarfile != NULL; do that test first, and then if it
fails, do the strcmp after that.

Also, if we're going to test the return value of fclose(), shouldn't
we also be checking the return value of gzclose()?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-03-28 12:44:17 Re: Improvement of log messages in pg_basebackup
Previous Message Shigeru HANADA 2012-03-28 12:25:45 Re: pgsql_fdw, FDW for PostgreSQL server