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
53b54553
Commit
53b54553
authored
20 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Improve thread test program to show if non-*_r functions are even called.
parent
37fa3b6c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/tools/thread/thread_test.c
+76
-2
76 additions, 2 deletions
src/tools/thread/thread_test.c
with
76 additions
and
2 deletions
src/tools/thread/thread_test.c
+
76
−
2
View file @
53b54553
...
...
@@ -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.1
6
2004/04/
06 13:55:17
momjian Exp $
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.1
7
2004/04/
21 20:51:54
momjian Exp $
*
* This program tests to see if your standard libc functions use
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
...
...
@@ -32,6 +32,8 @@
#include
<fcntl.h>
#include
<errno.h>
#include
"postgres.h"
void
func_call_1
(
void
);
void
func_call_2
(
void
);
...
...
@@ -52,6 +54,11 @@ struct passwd *passwd_p2;
struct
hostent
*
hostent_p1
;
struct
hostent
*
hostent_p2
;
bool
gethostbyname_threadsafe
;
bool
getpwuid_threadsafe
;
bool
strerror_threadsafe
;
bool
platform_is_threadsafe
=
true
;
pthread_mutex_t
init_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -90,26 +97,93 @@ defines to your template/$port file before compiling this program.\n\n"
printf
(
"Add this to your template/$port file:
\n\n
"
);
if
(
strerror_p1
!=
strerror_p2
)
{
printf
(
"STRERROR_THREADSAFE=yes
\n
"
);
strerror_threadsafe
=
true
;
}
else
{
printf
(
"STRERROR_THREADSAFE=no
\n
"
);
strerror_threadsafe
=
false
;
}
if
(
passwd_p1
!=
passwd_p2
)
{
printf
(
"GETPWUID_THREADSAFE=yes
\n
"
);
getpwuid_threadsafe
=
true
;
}
else
{
printf
(
"GETPWUID_THREADSAFE=no
\n
"
);
getpwuid_threadsafe
=
false
;
}
if
(
hostent_p1
!=
hostent_p2
)
{
printf
(
"GETHOSTBYNAME_THREADSAFE=yes
\n
"
);
gethostbyname_threadsafe
=
true
;
}
else
{
printf
(
"GETHOSTBYNAME_THREADSAFE=no
\n
"
);
gethostbyname_threadsafe
=
false
;
}
pthread_mutex_unlock
(
&
init_mutex
);
/* let children exit */
pthread_join
(
thread1
,
NULL
);
/* clean up children */
pthread_join
(
thread2
,
NULL
);
return
0
;
printf
(
"
\n
"
);
#ifdef HAVE_STRERROR_R
printf
(
"Your system has sterror_r(), so it doesn't use strerror().
\n
"
);
#else
printf
(
"Your system uses strerror().
\n
"
);
if
(
!
strerror_threadsafe
)
{
platform_is_threadsafe
=
false
;
printf
(
"That function is not thread-safe
\n
"
);
}
#endif
#ifdef HAVE_GETPWUID_R
printf
(
"Your system has getpwuid_r(), so it doesn't use getpwuid().
\n
"
);
#else
printf
(
"Your system uses getpwuid().
\n
"
);
if
(
!
getpwuid_threadsafe
)
{
platform_is_threadsafe
=
false
;
printf
(
"That function is not thread-safe
\n
"
);
}
#endif
#ifdef HAVE_GETADDRINFO
printf
(
"Your system has getaddrinfo(), so it doesn't use gethostbyname()
\n
"
"or gethostbyname_r().
\n
"
);
#else
#ifdef HAVE_GETHOSTBYNAME_R
printf
(
"Your system has gethostbyname_r(), so it doesn't use gethostbyname().
\n
"
);
#else
printf
(
"Your system uses gethostbyname().
\n
"
);
if
(
!
gethostbyname_threadsafe
)
{
platform_is_threadsafe
=
false
;
printf
(
"That function is not thread-safe
\n
"
);
}
#endif
#endif
if
(
!
platform_is_threadsafe
)
{
printf
(
"
\n
** YOUR PLATFORM IS NOT THREADSAFE **
\n
"
);
return
1
;
}
else
{
printf
(
"
\n
YOUR PLATFORM IS THREADSAFE
\n
"
);
return
0
;
}
}
void
func_call_1
(
void
)
{
...
...
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