Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group