Commit 31f48c9a authored by Bruce Momjian's avatar Bruce Momjian

Update thread test to only test for 'localhost' and local machine name.

parent d56b736d
...@@ -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.10 2004/04/04 17:23:54 momjian Exp $ * $PostgreSQL: pgsql/src/tools/thread/thread_test.c,v 1.11 2004/04/05 01:27:58 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.
...@@ -35,6 +35,8 @@ ...@@ -35,6 +35,8 @@
void func_call_1(void); void func_call_1(void);
void func_call_2(void); void func_call_2(void);
char myhostname[MAXHOSTNAMELEN];
int errno1_set = 0; int errno1_set = 0;
int errno2_set = 0; int errno2_set = 0;
...@@ -61,6 +63,12 @@ int main(int argc, char *argv[]) ...@@ -61,6 +63,12 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
if (gethostname(myhostname, MAXHOSTNAMELEN) != 0)
{
fprintf(stderr, "can not get local hostname, exiting\n");
exit(1);
}
printf("\ printf("\
Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'\n\ Make sure you have added any needed 'THREAD_CPPFLAGS' and 'THREAD_LIBS'\n\
defines to your template/$port file before compiling this program.\n\n" defines to your template/$port file before compiling this program.\n\n"
...@@ -128,8 +136,9 @@ void func_call_1(void) { ...@@ -128,8 +136,9 @@ void func_call_1(void) {
passwd_p1 = NULL; /* force thread-safe failure report */ passwd_p1 = NULL; /* force thread-safe failure report */
} }
hostent_p1 = gethostbyname("www.yahoo.com"); /* threads do this in opposite order */
p = gethostbyname("www.weather.com"); hostent_p1 = gethostbyname(myhostname);
p = gethostbyname("localhost");
if (hostent_p1 != p) if (hostent_p1 != p)
{ {
printf("Your gethostbyname() changes the static memory area between calls\n"); printf("Your gethostbyname() changes the static memory area between calls\n");
...@@ -174,8 +183,9 @@ void func_call_2(void) { ...@@ -174,8 +183,9 @@ void func_call_2(void) {
passwd_p2 = NULL; /* force thread-safe failure report */ passwd_p2 = NULL; /* force thread-safe failure report */
} }
hostent_p2 = gethostbyname("www.google.com"); /* threads do this in opposite order */
p = gethostbyname("www.postgresql.org"); hostent_p2 = gethostbyname("localhost");
p = gethostbyname(myhostname);
if (hostent_p2 != p) if (hostent_p2 != p)
{ {
printf("Your gethostbyname() changes the static memory area between calls\n"); printf("Your gethostbyname() changes the static memory area between calls\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment