Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
f687c7e8
Commit
f687c7e8
authored
20 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Use mktemp for temporary file names, per suggestion from Peter.
parent
b498b795
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tools/thread/thread_test.c
+24
-10
24 additions, 10 deletions
src/tools/thread/thread_test.c
with
24 additions
and
10 deletions
src/tools/thread/thread_test.c
+
24
−
10
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 1
7:22:4
1 momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.2
7
2004/04/27 1
8: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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment