Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f687c7e8
Commit
f687c7e8
authored
Apr 27, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use mktemp for temporary file names, per suggestion from Peter.
parent
b498b795
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
src/tools/thread/thread_test.c
src/tools/thread/thread_test.c
+24
-10
No files found.
src/tools/thread/thread_test.c
View file @
f687c7e8
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.2
6 2004/04/27 17:22:4
1 momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.2
7 2004/04/27 18:36:3
1 momjian Exp $
*
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
...
...
@@ -49,6 +49,12 @@ main(int argc, char *argv[])
void
func_call_1
(
void
);
void
func_call_2
(
void
);
#define TEMP_FILENAME_1 "/tmp/thread_test.1.XXXXX"
#define TEMP_FILENAME_2 "/tmp/thread_test.2.XXXXX"
char
*
temp_filename_1
;
char
*
temp_filename_2
;
pthread_mutex_t
init_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
volatile
int
thread1_done
=
0
;
...
...
@@ -90,6 +96,14 @@ main(int argc, char *argv[])
return
1
;
}
/* Make temp filenames, might not have strdup() */
temp_filename_1
=
malloc
(
strlen
(
TEMP_FILENAME_1
)
+
1
);
strcpy
(
temp_filename_1
,
TEMP_FILENAME_1
);
mktemp
(
temp_filename_1
);
temp_filename_2
=
malloc
(
strlen
(
TEMP_FILENAME_2
)
+
1
);
strcpy
(
temp_filename_2
,
TEMP_FILENAME_2
);
mktemp
(
temp_filename_2
);
#if !defined(HAVE_GETADDRINFO) && !defined(HAVE_GETHOSTBYNAME_R)
if
(
gethostname
(
myhostname
,
MAXHOSTNAMELEN
)
!=
0
)
{
...
...
@@ -195,10 +209,10 @@ func_call_1(void)
void
*
p
;
#endif
unlink
(
"/tmp/thread_test.1"
);
unlink
(
temp_filename_1
);
/* create, then try to fail on exclusive create open */
if
(
open
(
"/tmp/thread_test.1"
,
O_RDWR
|
O_CREAT
,
0600
)
<
0
||
open
(
"/tmp/thread_test.1"
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
)
>=
0
)
if
(
open
(
temp_filename_1
,
O_RDWR
|
O_CREAT
,
0600
)
<
0
||
open
(
temp_filename_1
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
)
>=
0
)
{
fprintf
(
stderr
,
"Could not create file in /tmp or
\n
"
);
fprintf
(
stderr
,
"Could not generate failure for create file in /tmp **
\n
exiting
\n
"
);
...
...
@@ -215,10 +229,10 @@ func_call_1(void)
if
(
errno
!=
EEXIST
)
{
fprintf
(
stderr
,
"errno not thread-safe **
\n
exiting
\n
"
);
unlink
(
"/tmp/thread_test.1"
);
unlink
(
temp_filename_1
);
exit
(
1
);
}
unlink
(
"/tmp/thread_test.1"
);
unlink
(
temp_filename_1
);
#ifndef HAVE_STRERROR_R
strerror_p1
=
strerror
(
EACCES
);
...
...
@@ -266,9 +280,9 @@ func_call_2(void)
void
*
p
;
#endif
unlink
(
"/tmp/thread_test.2"
);
unlink
(
temp_filename_2
);
/* open non-existant file */
if
(
open
(
"/tmp/thread_test.2"
,
O_RDONLY
,
0600
)
>=
0
)
if
(
open
(
temp_filename_2
,
O_RDONLY
,
0600
)
>=
0
)
{
fprintf
(
stderr
,
"Read-only open succeeded without create **
\n
exiting
\n
"
);
exit
(
1
);
...
...
@@ -284,10 +298,10 @@ func_call_2(void)
if
(
errno
!=
ENOENT
)
{
fprintf
(
stderr
,
"errno not thread-safe **
\n
exiting
\n
"
);
unlink
(
"/tmp/thread_test.A"
);
unlink
(
temp_filename_2
);
exit
(
1
);
}
unlink
(
"/tmp/thread_test.2"
);
unlink
(
temp_filename_2
);
#ifndef HAVE_STRERROR_R
strerror_p2
=
strerror
(
EINVAL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment