Skip to content

Commit 31f48c9

Browse files
committed
Update thread test to only test for 'localhost' and local machine name.
1 parent d56b736 commit 31f48c9

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/tools/thread/thread_test.c

Lines changed: 15 additions & 5 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.10 2004/04/04 17:23:54 momjian Exp $
9+
* $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.11 2004/04/05 01:27:58 momjian Exp $
1010
*
1111
* This program tests to see if your standard libc functions use
1212
* pthread_setspecific()/pthread_getspecific() to be thread-safe.
@@ -35,6 +35,8 @@
3535
void func_call_1(void);
3636
void func_call_2(void);
3737

38+
char myhostname[MAXHOSTNAMELEN];
39+
3840
int errno1_set = 0;
3941
int errno2_set = 0;
4042

@@ -61,6 +63,12 @@ int main(int argc, char *argv[])
6163
return 1;
6264
}
6365

66+
if (gethostname(myhostname, MAXHOSTNAMELEN) != 0)
67+
{
68+
fprintf(stderr, "can not get local hostname, exiting\n");
69+
exit(1);
70+
}
71+
6472
printf("\
6573
Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'\n\
6674
defines to your template/$port file before compiling this program.\n\n"
@@ -128,8 +136,9 @@ void func_call_1(void) {
128136
passwd_p1 = NULL; /* force thread-safe failure report */
129137
}
130138

131-
hostent_p1 = gethostbyname("www.yahoo.com");
132-
p = gethostbyname("www.weather.com");
139+
/* threads do this in opposite order */
140+
hostent_p1 = gethostbyname(myhostname);
141+
p = gethostbyname("localhost");
133142
if (hostent_p1 != p)
134143
{
135144
printf("Your gethostbyname() changes the static memory area between calls\n");
@@ -174,8 +183,9 @@ void func_call_2(void) {
174183
passwd_p2 = NULL; /* force thread-safe failure report */
175184
}
176185

177-
hostent_p2 = gethostbyname("www.google.com");
178-
p = gethostbyname("www.postgresql.org");
186+
/* threads do this in opposite order */
187+
hostent_p2 = gethostbyname("localhost");
188+
p = gethostbyname(myhostname);
179189
if (hostent_p2 != p)
180190
{
181191
printf("Your gethostbyname() changes the static memory area between calls\n");

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