Thread: solaris libpq threaded build fails
for anyone interested.... Solaris 2.5.1 with --enable-thread-safety configure:25848: gcc -o conftest -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -pthreads -pthreads -D_REENTRANT -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE -lgcc_s -lvsnprintf conftest.c -lz -lposix4 -lsocket -ldl -lm -lpthread -lpthread >&5 In file included from conftest.c:129: ./src/test/thread/thread_test.c: In function `main': ./src/test/thread/thread_test.c:179: warning: implicit declaration of function `mkstemp' ./src/test/thread/thread_test.c:188: warning: implicit declaration of function `gethostname' Undefined first referenced symbol in file gethostbyname /var/tmp//ccclix3s.o (symbol belongs to implicit dependency /usr/lib/libnsl.so.1) ld: fatal: Symbol referencing errors. No output written to conftest collect2: ld returned 1 exit status configure:25851: $? = 1 configure: program exited with status 1 configure: failed program was: so far: hpux 10.20, solaris 2.5.1 and cygwin builds all fail when thread safe is enable. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
I supposed Solaris 2.5.1 (release 1996) is just too old to add threading, and this code has been unchanged for years. --------------------------------------------------------------------------- Andrew Chernow wrote: > for anyone interested.... > > Solaris 2.5.1 with --enable-thread-safety > > configure:25848: gcc -o conftest -O2 -Wall -Wmissing-prototypes > -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels > -fno-strict-aliasing -fwrapv -pthreads -pthreads -D_REENTRANT > -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE -lgcc_s > -lvsnprintf conftest.c -lz -lposix4 -lsocket -ldl -lm -lpthread > -lpthread >&5 > In file included from conftest.c:129: > ./src/test/thread/thread_test.c: In function `main': > ./src/test/thread/thread_test.c:179: warning: implicit declaration of > function `mkstemp' > ./src/test/thread/thread_test.c:188: warning: implicit declaration of > function `gethostname' > Undefined first referenced > symbol in file > gethostbyname /var/tmp//ccclix3s.o (symbol > belongs to implicit dependency /usr/lib/libnsl.so.1) > ld: fatal: Symbol referencing errors. No output written to conftest > collect2: ld returned 1 exit status > configure:25851: $? = 1 > configure: program exited with status 1 > configure: failed program was: > > so far: hpux 10.20, solaris 2.5.1 and cygwin builds all fail when thread > safe is enable. > > -- > Andrew Chernow > eSilo, LLC > every bit counts > http://www.esilo.com/ > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
2009/1/12 Bruce Momjian <bruce@momjian.us>: > > I supposed Solaris 2.5.1 (release 1996) is just too old to add > threading, and this code has been unchanged for years. > > --------------------------------------------------------------------------- > > Andrew Chernow wrote: >> for anyone interested.... >> >> Solaris 2.5.1 with --enable-thread-safety >> >> configure:25848: gcc -o conftest -O2 -Wall -Wmissing-prototypes >> -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels >> -fno-strict-aliasing -fwrapv -pthreads -pthreads -D_REENTRANT >> -D_THREAD_SAFE -D_POSIX_PTHREAD_SEMANTICS -DIN_CONFIGURE -lgcc_s >> -lvsnprintf conftest.c -lz -lposix4 -lsocket -ldl -lm -lpthread >> -lpthread >&5 >> In file included from conftest.c:129: >> ./src/test/thread/thread_test.c: In function `main': >> ./src/test/thread/thread_test.c:179: warning: implicit declaration of >> function `mkstemp' >> ./src/test/thread/thread_test.c:188: warning: implicit declaration of >> function `gethostname' >> Undefined first referenced >> symbol in file >> gethostbyname /var/tmp//ccclix3s.o (symbol >> belongs to implicit dependency /usr/lib/libnsl.so.1) >> ld: fatal: Symbol referencing errors. No output written to conftest >> collect2: ld returned 1 exit status >> configure:25851: $? = 1 >> configure: program exited with status 1 >> configure: failed program was: >> >> so far: hpux 10.20, solaris 2.5.1 and cygwin builds all fail when thread >> safe is enable. >> Sun garantee 10 years of appilcation compatibility, now we are in 11 version. thread-safety is the only option that fails? >> -- >> Andrew Chernow >> eSilo, LLC >> every bit counts >> http://www.esilo.com/ >> >> -- >> Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) >> To make changes to your subscription: >> http://www.postgresql.org/mailpref/pgsql-hackers > > -- > Bruce Momjian <bruce@momjian.us> http://momjian.us > EnterpriseDB http://enterprisedb.com > > + If your life is a hard drive, Christ can be your backup. + > > -- > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-hackers > -- Emanuel Calvo Franco ArPUG / AOSUG MemberPostgresql Support & Admin
Bruce Momjian wrote: > I supposed Solaris 2.5.1 (release 1996) is just too old to add > threading, and this code has been unchanged for years. > Yeah, its old. Unfortunately for us, we still have to support it. To set the record straight, the issue is not threads. Threads work fine on 2.5.1. This is a configure system linking issue, "gethostbyname" requires linking with libnsl.so. So, thread_test.c must link with -lnsl. The bigger issue is that the configure script needs to include -lnsl for older solaris platforms. Solaris 2.5.1 has "gethostbyname_r" but the configure check fails for the same reason. configure:19821: checking for gethostbyname_r configure:19877: gcc -o conftest -O2 -Wall [...snip...] Undefined first referenced symbol in file gethostbyname_r /var/tmp//ccSuGLEn.o (symbol belongs to implicit dependency /usr/lib/libnsl.so.1) ld: fatal: Symbol referencing errors. No output written to conftest collect2: ld returned 1 exit status This is why thread_test.c thought it had to fall back on gethostbyname in the first place. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
Andrew Chernow wrote: > Bruce Momjian wrote: >> I supposed Solaris 2.5.1 (release 1996) is just too old to add >> threading, and this code has been unchanged for years. >> > > Yeah, its old. Unfortunately for us, we still have to support it. > > To set the record straight, the issue is not threads. Threads work fine > on 2.5.1. This is a configure system linking issue, "gethostbyname" > requires linking with libnsl.so. So, thread_test.c must link with -lnsl. > > The bigger issue is that the configure script needs to include -lnsl for > older solaris platforms. Solaris 2.5.1 has "gethostbyname_r" but the > configure check fails for the same reason. > > configure:19821: checking for gethostbyname_r > configure:19877: gcc -o conftest -O2 -Wall [...snip...] > Undefined first referenced > symbol in file > gethostbyname_r /var/tmp//ccSuGLEn.o (symbol > belongs to implicit dependency /usr/lib/libnsl.so.1) > ld: fatal: Symbol referencing errors. No output written to conftest > collect2: ld returned 1 exit status > > This is why thread_test.c thought it had to fall back on gethostbyname > in the first place. > Forgot to mention, there is an easy fix: ~]# LDFLAGS="-lnsl" ./configure --enable-thread-safety -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
Andrew Chernow wrote: > Bruce Momjian wrote: > > I supposed Solaris 2.5.1 (release 1996) is just too old to add > > threading, and this code has been unchanged for years. > > > > Yeah, its old. Unfortunately for us, we still have to support it. > > To set the record straight, the issue is not threads. Threads work fine > on 2.5.1. This is a configure system linking issue, "gethostbyname" > requires linking with libnsl.so. So, thread_test.c must link with -lnsl. > > The bigger issue is that the configure script needs to include -lnsl for > older solaris platforms. Solaris 2.5.1 has "gethostbyname_r" but the > configure check fails for the same reason. > > configure:19821: checking for gethostbyname_r > configure:19877: gcc -o conftest -O2 -Wall [...snip...] > Undefined first referenced > symbol in file > gethostbyname_r /var/tmp//ccSuGLEn.o (symbol > belongs to implicit dependency /usr/lib/libnsl.so.1) > ld: fatal: Symbol referencing errors. No output written to conftest > collect2: ld returned 1 exit status > > This is why thread_test.c thought it had to fall back on gethostbyname > in the first place. Well, part of the problem is we are running the thread test program from _within_ configure so we don't have everything set up yet to work around this problem, and with an OS that old, is it worth trying? If you give me something that will uniquely indentify this platform/version in configure and in C, I might be able to send you a test patch to try, and if it works, I can apply it for 8.4. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Andrew Chernow wrote: > Andrew Chernow wrote: > > Bruce Momjian wrote: > >> I supposed Solaris 2.5.1 (release 1996) is just too old to add > >> threading, and this code has been unchanged for years. > >> > > > > Yeah, its old. Unfortunately for us, we still have to support it. > > > > To set the record straight, the issue is not threads. Threads work fine > > on 2.5.1. This is a configure system linking issue, "gethostbyname" > > requires linking with libnsl.so. So, thread_test.c must link with -lnsl. > > > > The bigger issue is that the configure script needs to include -lnsl for > > older solaris platforms. Solaris 2.5.1 has "gethostbyname_r" but the > > configure check fails for the same reason. > > > > configure:19821: checking for gethostbyname_r > > configure:19877: gcc -o conftest -O2 -Wall [...snip...] > > Undefined first referenced > > symbol in file > > gethostbyname_r /var/tmp//ccSuGLEn.o (symbol > > belongs to implicit dependency /usr/lib/libnsl.so.1) > > ld: fatal: Symbol referencing errors. No output written to conftest > > collect2: ld returned 1 exit status > > > > This is why thread_test.c thought it had to fall back on gethostbyname > > in the first place. > > > > Forgot to mention, there is an easy fix: > > ~]# LDFLAGS="-lnsl" ./configure --enable-thread-safety But I assume that only works if I use gethostbyname_r(), right? But we do check for that in thread_test.c. So that library that is all that is needed? -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
>>> >> Forgot to mention, there is an easy fix: >> >> ~]# LDFLAGS="-lnsl" ./configure --enable-thread-safety > > But I assume that only works if I use gethostbyname_r(), right? No, works for gethostbyname as well. They are all in libnsl. > But we do check for that in thread_test.c. The problem with the current check is its only an AC_CHECK_FUNCS. We need an AC_SEARCH_LIBS first so the proper -llibrary is appended to LIBS, which is used by AC_CHECK_FUNCS. AC_SEARCH_LIBS(gethostbyname_r, c nsl) AC_CHECK_FUNCS([strerror_r getpwuid_r gethostbyname_r]) (AC_CHECK_FUNCS from configure.in line 1371) > So that library that is all that is > needed? > It worked for me. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
Andrew Chernow wrote: > The problem with the current check is its only an AC_CHECK_FUNCS. We > need an AC_SEARCH_LIBS first so the proper -llibrary is appended to > LIBS, which is used by AC_CHECK_FUNCS. > > AC_SEARCH_LIBS(gethostbyname_r, c nsl) Just don't put "c" in there. You usually don't want an explicit -lc to appear in your link commands.
>> AC_SEARCH_LIBS(gethostbyname_r, c nsl) > > Just don't put "c" in there. You usually don't want an explicit -lc to > appear in your link commands. Correct. Copied that from an internal project, which I should fix. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
Andrew Chernow wrote: > > >>> > >> Forgot to mention, there is an easy fix: > >> > >> ~]# LDFLAGS="-lnsl" ./configure --enable-thread-safety > > > > But I assume that only works if I use gethostbyname_r(), right? > > No, works for gethostbyname as well. They are all in libnsl. > > > But we do check for that in thread_test.c. > > The problem with the current check is its only an AC_CHECK_FUNCS. > We need an AC_SEARCH_LIBS first so the proper -llibrary is > appended to LIBS, which is used by AC_CHECK_FUNCS. > > AC_SEARCH_LIBS(gethostbyname_r, c nsl) AC_CHECK_FUNCS([strerror_r > getpwuid_r gethostbyname_r]) > > (AC_CHECK_FUNCS from configure.in line 1371) OK, patch attached and applied to CVS HEAD. The nsl (not 'nls') library check was removed in Postgres 8.2 here: http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/configure.in.diff?r1=1.448;r2=1.445;f=h The new code is more specific by testing for gethostbyname_r() and only on Solaris. I also added a comment about why it was re-added. The next question is do we backpatch this back to 8.2? -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Index: configure =================================================================== RCS file: /cvsroot/pgsql/configure,v retrieving revision 1.626 diff -c -c -r1.626 configure *** configure 11 Jan 2009 18:02:15 -0000 1.626 --- configure 14 Jan 2009 16:37:21 -0000 *************** *** 7743,7748 **** --- 7743,7836 ---- fi + # Required for thread_test.c on Solaris 2.5: + case $host_os in + solaris*) + { echo "$as_me:$LINENO: checking for library containing gethostbyname_r" >&5 + echo $ECHO_N "checking for library containing gethostbyname_r... $ECHO_C" >&6; } + if test "${ac_cv_search_gethostbyname_r+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 + else + ac_func_search_save_LIBS=$LIBS + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + + /* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ + #ifdef __cplusplus + extern "C" + #endif + char gethostbyname_r (); + int + main () + { + return gethostbyname_r (); + ; + return 0; + } + _ACEOF + for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext + if { (ac_try="$ac_link" + case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; + esac + eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_gethostbyname_r=$ac_res + else + echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + + fi + + rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_gethostbyname_r+set}" = set; then + break + fi + done + if test "${ac_cv_search_gethostbyname_r+set}" = set; then + : + else + ac_cv_search_gethostbyname_r=no + fi + rm conftest.$ac_ext + LIBS=$ac_func_search_save_LIBS + fi + { echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname_r" >&5 + echo "${ECHO_T}$ac_cv_search_gethostbyname_r" >&6; } + ac_res=$ac_cv_search_gethostbyname_r + if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + fi + + ;; + esac # Cygwin: { echo "$as_me:$LINENO: checking for library containing shmget" >&5 echo $ECHO_N "checking for library containing shmget... $ECHO_C" >&6; } Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.585 diff -c -c -r1.585 configure.in *** configure.in 11 Jan 2009 18:02:17 -0000 1.585 --- configure.in 14 Jan 2009 16:37:21 -0000 *************** *** 870,875 **** --- 870,881 ---- AC_SEARCH_LIBS(crypt, crypt) # Solaris: AC_SEARCH_LIBS(fdatasync, [rt posix4]) + # Required for thread_test.c on Solaris 2.5: + case $host_os in + solaris*) + AC_SEARCH_LIBS(gethostbyname_r, nsl) + ;; + esac # Cygwin: AC_SEARCH_LIBS(shmget, cygipc)
On 1/14/09, Bruce Momjian <bruce@momjian.us> wrote: > OK, patch attached and applied to CVS HEAD. The nsl (not 'nls') library > check was removed in Postgres 8.2 here: As long as you are looking at this, can you take a peek at this patch? http://archives.free.net.ph/message/20081116.053100.15b5801d.fi.html We had a similar problem on hpux 10.20. This was more invasive change though.. At the time, Tom was ambivalent and Dunstan voted that the platform was too old, so it never went in. merlin
Merlin Moncure wrote: > On 1/14/09, Bruce Momjian <bruce@momjian.us> wrote: > > OK, patch attached and applied to CVS HEAD. The nsl (not 'nls') library > > check was removed in Postgres 8.2 here: > > As long as you are looking at this, can you take a peek at this patch? > http://archives.free.net.ph/message/20081116.053100.15b5801d.fi.html > > We had a similar problem on hpux 10.20. This was more invasive change > though.. At the time, Tom was ambivalent and Dunstan voted that the > platform was too old, so it never went in. Thanks, I looked it over. It does have the danger of affecting other platforms, so there would have to be more checks in there. Also the calling of the function with all null pointers seems dangerous, though I am not sure how else we could test this. It might be safer to create a conflicting function prototype and see if that throws a warning. I did a Google search and it seems there isn't an easy way to do the configure check except the approach you have taken. Your changes to thread.c seem fine. Comp.programming.threads, has a pretty ugly autoconf example in their FAQ with the conclusion: http://www.lambdacs.com/cpt/FAQ.html> Whom do I shoot?take your pick :-( Let me see if I can work up a more minimal patch. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Bruce Momjian wrote: > > Also the > calling of the function with all null pointers seems dangerous, Its only trying to compile it, AC_TRY_COMPILE, not execute it. I don't "think?" the NULL pointers could ever raise havoc. -- Andrew Chernow eSilo, LLC every bit counts http://www.esilo.com/
Bruce Momjian wrote: > Merlin Moncure wrote: > > On 1/14/09, Bruce Momjian <bruce@momjian.us> wrote: > > > OK, patch attached and applied to CVS HEAD. The nsl (not 'nls') library > > > check was removed in Postgres 8.2 here: > > > > As long as you are looking at this, can you take a peek at this patch? > > http://archives.free.net.ph/message/20081116.053100.15b5801d.fi.html > > > > We had a similar problem on hpux 10.20. This was more invasive change > > though.. At the time, Tom was ambivalent and Dunstan voted that the > > platform was too old, so it never went in. > > Thanks, I looked it over. It does have the danger of affecting other > platforms, so there would have to be more checks in there. Also the > calling of the function with all null pointers seems dangerous, though I > am not sure how else we could test this. It might be safer to create a > conflicting function prototype and see if that throws a warning. > > I did a Google search and it seems there isn't an easy way to do the > configure check except the approach you have taken. Your changes to > thread.c seem fine. > > Comp.programming.threads, has a pretty ugly autoconf example in their > FAQ with the conclusion: > > http://www.lambdacs.com/cpt/FAQ.html > > > Whom do I shoot? > > take your pick :-( > > Let me see if I can work up a more minimal patch. OK, I ended up doing a compile test as you suggested because I was worried that a mismatched 'const' might throw an error. The patch is very similar to the one posted, though perhaps a little cleaner. I don't need the #undef _XOPEN_SOURCE_EXTENDED in autoconf because I am testing for the 5-argument version. Would someone please test this to make sure it works on their platforms. Is there any objection to applying this to 8.4? While the operating system is old, it seems we are having new users use threading on these older operating systems, hence the need for a patch. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + Index: configure =================================================================== RCS file: /cvsroot/pgsql/configure,v retrieving revision 1.628 diff -c -c -r1.628 configure *** configure 14 Jan 2009 18:10:21 -0000 1.628 --- configure 14 Jan 2009 22:00:25 -0000 *************** *** 20379,20384 **** --- 20379,20440 ---- + if test "$enable_thread_safety" = yes -a x"$ac_cv_func_gethostbyname_r" = x"yes" ; then + { echo "$as_me:$LINENO: checking gethostbyname_r argument count" >&5 + echo $ECHO_N "checking gethostbyname_r argument count... $ECHO_C" >&6; } + # Check to see if 5-argument call generates an error + cat >conftest.$ac_ext <<_ACEOF + /* confdefs.h. */ + _ACEOF + cat confdefs.h >>conftest.$ac_ext + cat >>conftest.$ac_ext <<_ACEOF + /* end confdefs.h. */ + #include <netdb.h> + int + main () + { + (void) gethostbyname_r (NULL, NULL, NULL, 0, NULL); + ; + return 0; + } + _ACEOF + rm -f conftest.$ac_objext + if { (ac_try="$ac_compile" + case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; + esac + eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + + cat >>confdefs.h <<\_ACEOF + #define GETHOSTBYNAME_R_ARGCNT 3 + _ACEOF + { echo "$as_me:$LINENO: result: 5" >&5 + echo "${ECHO_T}5" >&6; } + else + echo "$as_me: failed program was:" >&5 + sed 's/^/| /' conftest.$ac_ext >&5 + + + cat >>confdefs.h <<\_ACEOF + #define GETHOSTBYNAME_R_ARGCNT 5 + _ACEOF + { echo "$as_me:$LINENO: result: 3" >&5 + echo "${ECHO_T}3" >&6; } + fi + + rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi # This test makes sure that run tests work at all. Sometimes a shared # library is found by the linker, but the runtime linker can't find it. Index: configure.in =================================================================== RCS file: /cvsroot/pgsql/configure.in,v retrieving revision 1.587 diff -c -c -r1.587 configure.in *** configure.in 14 Jan 2009 18:10:21 -0000 1.587 --- configure.in 14 Jan 2009 22:00:25 -0000 *************** *** 1417,1422 **** --- 1417,1430 ---- AC_SUBST(LDAP_LIBS_FE) AC_SUBST(LDAP_LIBS_BE) + if test "$enable_thread_safety" = yes -a x"$ac_cv_func_gethostbyname_r" = x"yes" ; then + AC_MSG_CHECKING([gethostbyname_r argument count]) + # Check to see if 5-argument call generates an error + AC_TRY_COMPILE([#include <netdb.h>], + [(void) gethostbyname_r (NULL, NULL, NULL, 0, NULL);], + [AC_DEFINE(GETHOSTBYNAME_R_ARGCNT, 3, [Define to the number of arguments gethostbyname_r accepts]) AC_MSG_RESULT(5)], + [AC_DEFINE(GETHOSTBYNAME_R_ARGCNT, 5, [Define to the number of arguments gethostbyname_r accepts]) AC_MSG_RESULT(3)]) + fi # This test makes sure that run tests work at all. Sometimes a shared # library is found by the linker, but the runtime linker can't find it. Index: src/port/thread.c =================================================================== RCS file: /cvsroot/pgsql/src/port/thread.c,v retrieving revision 1.41 diff -c -c -r1.41 thread.c *** src/port/thread.c 14 Jan 2009 21:18:30 -0000 1.41 --- src/port/thread.c 14 Jan 2009 22:00:28 -0000 *************** *** 12,17 **** --- 12,22 ---- *------------------------------------------------------------------------- */ + /* Required to access struct hostent_data from c.h on older HPUX (e.g. 11) */ + #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_STRERROR_R) && defined(__hpux) + #undef _XOPEN_SOURCE_EXTENDED + #endif + #include "c.h" #include <pwd.h> *************** *** 127,132 **** --- 132,138 ---- { #if defined(FRONTEND) && defined(ENABLE_THREAD_SAFETY) && defined(HAVE_GETHOSTBYNAME_R) + #if GETHOSTBYNAME_R_ARGCNT == 5 /* * broken (well early POSIX draft) gethostbyname_r() which returns 'struct * hostent *' *************** *** 134,140 **** --- 140,163 ---- *result = gethostbyname_r(name, resultbuf, buffer, buflen, herrno); return (*result == NULL) ? -1 : 0; #else + /* even older 3-argument version of gethostbyname_r() */ + *result = NULL; + if (buflen < sizeof(struct hostent_data)) + { + /* linux man page says this gets set when buffer is too small */ + *herrno = ERANGE; + return -1; + } + + if (gethostbyname_r(name, resultbuf, (struct hostent_data *)buffer)) + { + *herrno = h_errno; + return -1; + } + *result = resultbuf; + #endif + #else /* no gethostbyname_r(), just use gethostbyname() */ *result = gethostbyname(name);
Bruce Momjian <bruce@momjian.us> writes: > Is there any objection to applying this to 8.4? Yes. I don't think we should bother with a one-operating-system patch for an OS version that was obsolete ten years ago. (Even if I am still running it ;-).) If we do this, the next thing will be trying to work around whatever threading bugs exist in the platform, and you can be sure there are some. regards, tom lane
Tom Lane wrote: > Bruce Momjian <bruce@momjian.us> writes: > > Is there any objection to applying this to 8.4? > > Yes. I don't think we should bother with a one-operating-system patch > for an OS version that was obsolete ten years ago. (Even if I am still > running it ;-).) If we do this, the next thing will be trying to work > around whatever threading bugs exist in the platform, and you can be > sure there are some. True, but from my reading AIX was also in the mix. We can just wait for another bug report, of course. -- Bruce Momjian <bruce@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. +
Bruce Momjian <bruce@momjian.us> writes: > Tom Lane wrote: >> Bruce Momjian <bruce@momjian.us> writes: >>> Is there any objection to applying this to 8.4? >> >> Yes. I don't think we should bother with a one-operating-system patch >> for an OS version that was obsolete ten years ago. (Even if I am still >> running it ;-).) If we do this, the next thing will be trying to work >> around whatever threading bugs exist in the platform, and you can be >> sure there are some. > True, but from my reading AIX was also in the mix. We can just wait for > another bug report, of course. I think the appropriate level of effort is just to document that we don't support threading on HPUX 10.x. And the same for whatever ancient AIX version might have the same problem ... regards, tom lane