Re: 9.2 pg_upgrade regression tests on WIndows - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: 9.2 pg_upgrade regression tests on WIndows
Date
Msg-id 20120906024548.GA9302@momjian.us
Whole thread Raw
In response to Re: 9.2 pg_upgrade regression tests on WIndows  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
On Wed, Sep  5, 2012 at 10:35:26PM -0400, Andrew Dunstan wrote:
> diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c
> index 99f5006..f84d857 100644
> --- a/contrib/pg_upgrade/exec.c
> +++ b/contrib/pg_upgrade/exec.c
> @@ -63,7 +63,25 @@ exec_prog(const char *log_file, const char *opt_log_file,
>      if (written >= MAXCMDLEN)
>          pg_log(PG_FATAL, "command too long\n");
>  
> -    if ((log = fopen_priv(log_file, "a")) == NULL)
> +#ifdef WIN32
> +    {
> +        /* 
> +         * Try to open the log file a few times in case the
> +         * server takes a bit longer than we'd like to release it.
> +         */
> +        int iter;
> +        for (iter = 0; iter < 5; iter++)
> +        {
> +            log = fopen_priv(log_file, "a");
> +            if (log != NULL || iter == 4)
> +                break;
> +            sleep(1);
> +        }
> +    }
> +#else
> +    log = fopen_priv(log_file, "a");
> +#endif
> +    if (log == NULL)
>          pg_log(PG_FATAL, "cannot write to log file %s\n", log_file);
>  #ifdef WIN32
>      fprintf(log, "\n\n");

Oh, also, we normally put the ifndef WIN32 code first because that is
our most common platform.  Also, is "|| iter == 4" necessary?

--  Bruce Momjian  <bruce@momjian.us>        http://momjian.us EnterpriseDB
http://enterprisedb.com
 + It's impossible for everything to be true. +



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: 9.2 pg_upgrade regression tests on WIndows
Next
From: Andrew Dunstan
Date:
Subject: Re: 9.2 pg_upgrade regression tests on WIndows