Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit31f48c9

Browse files
committed
Update thread test to only test for 'localhost' and local machine name.
1 parentd56b736 commit31f48c9

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
voidfunc_call_1(void);
3636
voidfunc_call_2(void);
3737

38+
charmyhostname[MAXHOSTNAMELEN];
39+
3840
interrno1_set=0;
3941
interrno2_set=0;
4042

@@ -61,6 +63,12 @@ int main(int argc, char *argv[])
6163
return1;
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)

[8]ページ先頭

©2009-2025 Movatter.jp