From 31f48c9afe4843b76a8f515dd32046214392ebae Mon Sep 17 00:00:00 2001 From: Bruce Momjian <bruce@momjian.us> Date: Mon, 5 Apr 2004 01:27:58 +0000 Subject: [PATCH] Update thread test to only test for 'localhost' and local machine name. --- src/tools/thread/thread_test.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tools/thread/thread_test.c b/src/tools/thread/thread_test.c index 3f4ad461aee..b8d26e98ce8 100644 --- a/src/tools/thread/thread_test.c +++ b/src/tools/thread/thread_test.c @@ -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.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 * pthread_setspecific()/pthread_getspecific() to be thread-safe. @@ -35,6 +35,8 @@ void func_call_1(void); void func_call_2(void); +char myhostname[MAXHOSTNAMELEN]; + int errno1_set = 0; int errno2_set = 0; @@ -61,6 +63,12 @@ int main(int argc, char *argv[]) return 1; } + if (gethostname(myhostname, MAXHOSTNAMELEN) != 0) + { + fprintf(stderr, "can not get local hostname, exiting\n"); + exit(1); + } + printf("\ 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" @@ -128,8 +136,9 @@ void func_call_1(void) { passwd_p1 = NULL; /* force thread-safe failure report */ } - hostent_p1 = gethostbyname("www.yahoo.com"); - p = gethostbyname("www.weather.com"); + /* threads do this in opposite order */ + hostent_p1 = gethostbyname(myhostname); + p = gethostbyname("localhost"); if (hostent_p1 != p) { printf("Your gethostbyname() changes the static memory area between calls\n"); @@ -174,8 +183,9 @@ void func_call_2(void) { passwd_p2 = NULL; /* force thread-safe failure report */ } - hostent_p2 = gethostbyname("www.google.com"); - p = gethostbyname("www.postgresql.org"); + /* threads do this in opposite order */ + hostent_p2 = gethostbyname("localhost"); + p = gethostbyname(myhostname); if (hostent_p2 != p) { printf("Your gethostbyname() changes the static memory area between calls\n"); -- GitLab