Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id BF0B1B5DBDC for ; Sun, 21 Aug 2011 02:09:15 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 60940-02 for ; Sun, 21 Aug 2011 05:09:09 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id AF6F2B5D803 for ; Sun, 21 Aug 2011 02:09:08 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p7L58xn1004742; Sun, 21 Aug 2011 01:08:59 -0400 (EDT) To: Bruce Momjian cc: Alex Soto , pgsql-bugs@postgresql.org Subject: Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms In-reply-to: <201108202224.p7KMOsH12990@momjian.us> References: <201108202224.p7KMOsH12990@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 20 Aug 2011 18:24:54 -0400" Date: Sun, 21 Aug 2011 01:08:59 -0400 Message-ID: <4741.1313903339@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.948 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-1.048 X-Spam-Level: X-Archive-Number: 201108/119 X-Sequence-Number: 30931 Bruce Momjian 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