From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Alex Soto <apsoto@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms
Date: Sun, 21 Aug 2011 01:08:59 -0400
Message-ID: <4741.1313903339@sss.pgh.pa.us> (raw)
In-Reply-To: <201108202224.p7KMOsH12990@momjian.us>
References: <201108202224.p7KMOsH12990@momjian.us>
Bruce Momjian <bruce@momjian.us> writes:
> Tom Lane wrote:
>> (The error message seems to be suffering from a bad case of copy-and-
>> paste-itis, too.)
> Actually, it is accurate. The code is:
> #ifdef WIN32
> h1 = CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL);
> h2 = CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL);
> if (h1 == INVALID_HANDLE_VALUE || GetLastError() != ERROR_FILE_EXISTS)
> #else
> if (open(TEMP_FILENAME_1, O_RDWR | O_CREAT, 0600) < 0 ||
> open(TEMP_FILENAME_1, O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
> #endif
> {
> fprintf(stderr, "Could not create file in current directory or\n");
> fprintf(stderr, "could not generate failure for create file in current directory **\nexiting\n");
> exit(1);
> }
> This code generates an errno == EEXIST in one thread, while another
> thread generates errno == ENOENT, and this is how we test for errno
> being thread-safe. If you have a cleaner way to do this, please let me
> know. mkdir()?
The problem with that is you're trying to make one error message serve
for two extremely different failure conditions. I think this should be
coded more like
if (open(TEMP_FILENAME_1, O_RDWR | O_CREAT, 0600) < 0)
{
report suitable failure message;
exit(1);
}
if (open(TEMP_FILENAME_1, O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
{
report suitable failure message;
exit(1);
}
You would probably find that the messages could be a lot more clear and
specific if they were done like that. Also, a file-related error
message that doesn't provide the filename nor strerror(errno) is pretty
much wrong on its face, in my book.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bruce@momjian.us, apsoto@gmail.com
Subject: Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms
In-Reply-To: <4741.1313903339@sss.pgh.pa.us>
References: <201108202224.p7KMOsH12990@momjian.us> <4741.1313903339@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox