Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms
От | Tom Lane |
---|---|
Тема | Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms |
Дата | |
Msg-id | 4741.1313903339@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: BUG #6166: configure from source fails with 'This platform is not thread-safe.' but was actually /tmp perms (Bruce Momjian <bruce@momjian.us>) |
Ответы |
Re: BUG #6166: configure from source fails with 'This
platform is not thread-safe.' but was actually /tmp perms
|
Список | pgsql-bugs |
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
В списке pgsql-bugs по дате отправления: