mirror of
https://github.com/postgres/postgres.git
synced 2025-05-02 11:44:50 +03:00
Properly call strerror() in thread test; add comments.
This commit is contained in:
parent
e319ec4b73
commit
5473f283f5
@ -157,7 +157,7 @@ main(int argc, char *argv[])
|
|||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to create thread 1: %s **\nexiting\n",
|
fprintf(stderr, "Failed to create thread 1: %s **\nexiting\n",
|
||||||
strerror(rc));
|
strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
rc = pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL);
|
rc = pthread_create(&thread2, NULL, (void *(*) (void *)) func_call_2, NULL);
|
||||||
@ -285,6 +285,11 @@ func_call_1(void)
|
|||||||
/* Set errno = EEXIST */
|
/* Set errno = EEXIST */
|
||||||
|
|
||||||
/* create, then try to fail on exclusive create open */
|
/* create, then try to fail on exclusive create open */
|
||||||
|
/*
|
||||||
|
* It would be great to check errno here but if errno is not thread-safe
|
||||||
|
* we might get a value from the other thread and mis-report the cause
|
||||||
|
* of the failure.
|
||||||
|
*/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if ((h1 = CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL)) ==
|
if ((h1 = CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, 0, NULL)) ==
|
||||||
INVALID_HANDLE_VALUE)
|
INVALID_HANDLE_VALUE)
|
||||||
@ -299,7 +304,7 @@ func_call_1(void)
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL)
|
if (CreateFile(TEMP_FILENAME_1, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, NULL)
|
||||||
!= INVALID_HANDLE_VALUE || GetLastError() != ERROR_FILE_EXISTS)
|
!= INVALID_HANDLE_VALUE)
|
||||||
#else
|
#else
|
||||||
if (open(TEMP_FILENAME_1, O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
|
if (open(TEMP_FILENAME_1, O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user