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
db9a9576
Commit
db9a9576
authored
21 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Add test for thread-safe errno to thread test program.
parent
4f0d027e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tools/thread/thread_test.c
+50
-2
50 additions, 2 deletions
src/tools/thread/thread_test.c
with
50 additions
and
2 deletions
src/tools/thread/thread_test.c
+
50
−
2
View file @
db9a9576
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.
7
2004/0
2/11 21:44:06
momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.
8
2004/0
3/27 23:02:44
momjian Exp $
*
*
* This program tests to see if your standard libc functions use
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
...
@@ -29,10 +29,15 @@
...
@@ -29,10 +29,15 @@
#include
<pwd.h>
#include
<pwd.h>
#include
<string.h>
#include
<string.h>
#include
<errno.h>
#include
<errno.h>
#include
<fcntl.h>
#include
<errno.h>
void
func_call_1
(
void
);
void
func_call_1
(
void
);
void
func_call_2
(
void
);
void
func_call_2
(
void
);
int
errno1_set
=
0
;
int
errno2_set
=
0
;
char
*
strerror_p1
;
char
*
strerror_p1
;
char
*
strerror_p2
;
char
*
strerror_p2
;
...
@@ -42,6 +47,9 @@ struct passwd *passwd_p2;
...
@@ -42,6 +47,9 @@ struct passwd *passwd_p2;
struct
hostent
*
hostent_p1
;
struct
hostent
*
hostent_p1
;
struct
hostent
*
hostent_p2
;
struct
hostent
*
hostent_p2
;
pthread_mutex_t
singlethread_lock1
=
PTHREAD_MUTEX_INITIALIZER
;
pthread_mutex_t
singlethread_lock2
=
PTHREAD_MUTEX_INITIALIZER
;
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
pthread_t
thread1
,
pthread_t
thread1
,
...
@@ -85,6 +93,29 @@ defines to your template/$port file before compiling this program.\n\n"
...
@@ -85,6 +93,29 @@ defines to your template/$port file before compiling this program.\n\n"
void
func_call_1
(
void
)
{
void
func_call_1
(
void
)
{
void
*
p
;
void
*
p
;
if
(
open
(
"/tmp/thread_test.1"
,
O_RDWR
|
O_CREAT
,
0600
)
<
0
)
{
fprintf
(
stderr
,
"Could not create file in /tmp, exiting
\n
"
);
exit
(
1
);
}
if
(
open
(
"/tmp/thread_test.1"
,
O_RDWR
|
O_CREAT
|
O_EXCL
,
0600
)
>=
0
)
{
fprintf
(
stderr
,
"Could not generate failure for create file in /tmp, exiting
\n
"
);
exit
(
1
);
}
/* wait for other thread to set errno */
errno1_set
=
1
;
while
(
errno2_set
==
0
)
/* loop */
;
if
(
errno
!=
EEXIST
)
{
fprintf
(
stderr
,
"errno not thread-safe; exiting
\n
"
);
unlink
(
"/tmp/thread_test.1"
);
exit
(
1
);
}
unlink
(
"/tmp/thread_test.1"
);
strerror_p1
=
strerror
(
EACCES
);
strerror_p1
=
strerror
(
EACCES
);
/*
/*
* If strerror() uses sys_errlist, the pointer might change for different
* If strerror() uses sys_errlist, the pointer might change for different
...
@@ -112,6 +143,23 @@ void func_call_1(void) {
...
@@ -112,6 +143,23 @@ void func_call_1(void) {
void
func_call_2
(
void
)
{
void
func_call_2
(
void
)
{
void
*
p
;
void
*
p
;
unlink
(
"/tmp/thread_test.2"
);
if
(
open
(
"/tmp/thread_test.2"
,
O_RDONLY
,
0600
)
>=
0
)
{
fprintf
(
stderr
,
"Read-only open succeeded without create, exiting
\n
"
);
exit
(
1
);
}
/* wait for other thread to set errno */
errno2_set
=
1
;
while
(
errno1_set
==
0
)
/* loop */
;
if
(
errno
!=
ENOENT
)
{
fprintf
(
stderr
,
"errno not thread-safe; exiting
\n
"
);
unlink
(
"/tmp/thread_test.A"
);
exit
(
1
);
}
strerror_p2
=
strerror
(
EINVAL
);
strerror_p2
=
strerror
(
EINVAL
);
/*
/*
* If strerror() uses sys_errlist, the pointer might change for different
* If strerror() uses sys_errlist, the pointer might change for different
...
...
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