From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Bruce Momjian <bruce(at)momjian(dot)us> |
Cc: | Alex Soto <apsoto(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms |
Date: | 2011-08-21 05:08:59 |
Message-ID: | 4741.1313903339@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Bruce Momjian <bruce(at)momjian(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Yoran Heling | 2011-08-21 12:00:55 | Segfault with before triggers and after triggers with a WHEN clause. |
Previous Message | Bruce Momjian | 2011-08-20 22:24:54 | Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms |