Skip to content

Commit b803cf4

Browse files
committed
Clean up thread test program.
1 parent db9a957 commit b803cf4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/tools/thread/thread_test.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.8 2004/03/27 23:02:44 momjian Exp $
9+
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.9 2004/03/28 02:37:31 momjian Exp $
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -93,15 +93,13 @@ defines to your template/$port file before compiling this program.\n\n"
9393
void func_call_1(void) {
9494
void *p;
9595

96-
if (open("/tmp/thread_test.1", O_RDWR | O_CREAT, 0600) < 0)
97-
{
98-
fprintf(stderr, "Could not create file in /tmp, exiting\n");
99-
exit(1);
100-
}
101-
102-
if (open("/tmp/thread_test.1", O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
96+
unlink("/tmp/thread_test.1");
97+
/* create, then try to fail on exclusive create open */
98+
if (open("/tmp/thread_test.1", O_RDWR | O_CREAT, 0600) < 0 ||
99+
open("/tmp/thread_test.1", O_RDWR | O_CREAT | O_EXCL, 0600) >= 0)
103100
{
104-
fprintf(stderr, "Could not generate failure for create file in /tmp, exiting\n");
101+
fprintf(stderr, "Could not create file in /tmp or\n");
102+
fprintf(stderr, "could not generate failure for create file in /tmp, exiting\n");
105103
exit(1);
106104
}
107105
/* wait for other thread to set errno */
@@ -144,6 +142,7 @@ void func_call_2(void) {
144142
void *p;
145143

146144
unlink("/tmp/thread_test.2");
145+
/* open non-existant file */
147146
if (open("/tmp/thread_test.2", O_RDONLY, 0600) >= 0)
148147
{
149148
fprintf(stderr, "Read-only open succeeded without create, exiting\n");
@@ -159,6 +158,7 @@ void func_call_2(void) {
159158
unlink("/tmp/thread_test.A");
160159
exit(1);
161160
}
161+
unlink("/tmp/thread_test.2");
162162

163163
strerror_p2 = strerror(EINVAL);
164164
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy