Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(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-20 22:24:54
Message-ID: 201108202224.p7KMOsH12990@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Tom Lane wrote:
> Alex Soto <apsoto(at)gmail(dot)com> writes:
> > Here's the section in the config.log in case it makes a difference
>
> > configure:28808: ./conftest
> > Could not create file in /tmp or
> > Could not generate failure for create file in /tmp **
> > exiting
> > configure:28812: $? = 1
> > configure: program exited with status 1
>
> [ greps... ] Oh, that error is coming from src/test/thread/thread_test.c.
>
> I wonder why we have that trying to write to /tmp at all, when all the
> other transient junk generated by configure is in the current directory.
> Bruce, do you have a good reason for doing it that way?

I have modified the code to use the current directory instead of /tmp.
I also cleaned up the #if defines and added some C comments.

> (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()?

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachment Content-Type Size
/rtmp/thread.diff text/x-diff 13.6 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2011-08-21 05:08:59 Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms
Previous Message Alejandro Sánchez 2011-08-20 17:16:59 Re: BUG #6120: Problem running post-install step in Mac OS X Lion (GM)