From a0ded9f0956529b55e3235569a1552f2d2f56483 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 2 Apr 2015 17:55:26 +0200 Subject: [PATCH] Port to Openindiana --- CHANGES | 3 +++ config.h.in | 9 ++++++++ configure.in | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++- error.c | 12 ++++++++-- test.sh | 10 ++++---- xio-listen.c | 4 +++- 6 files changed, 95 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index d452fa3..6cacfab 100644 --- a/CHANGES +++ b/CHANGES @@ -338,6 +338,9 @@ porting: Use 'environ' variable only when provided by runtime + Changes for Openindiana: define _XPG4_2, __EXTENSIONS__, + _POSIX_PTHREAD_SEMANTICS; and minor changes + new features: added option max-children that limits the number of concurrent child processes. Thanks to Sam Liddicott for providing the patch. diff --git a/config.h.in b/config.h.in index dc147af..9058bf8 100644 --- a/config.h.in +++ b/config.h.in @@ -344,6 +344,15 @@ /* Define if your termios.h likes _SVID3 defined */ #undef _SVID3 +/* Define if your sys/socket.h likes _XPG4_2 defined */ +#undef _XPG4_2 + +/* Define if your ctime_r() choices need _POSIX_PTHREAD_SEMANTICS */ +#undef _POSIX_PTHREAD_SEMANTICS + +/* Define if you need __EXTENSIONS__ */ +#undef __EXTENSIONS__ + /* Define if you have struct timespec (e.g. for nanosleep) */ #undef HAVE_STRUCT_TIMESPEC diff --git a/configure.in b/configure.in index 5678183..1d2e76f 100644 --- a/configure.in +++ b/configure.in @@ -1042,7 +1042,70 @@ if test $ac_cv_svid3 = yes; then fi AC_MSG_RESULT($ac_cv_svid3) - + +# Openindiana needs _XPG4_2 for CMSG stuff +AC_MSG_CHECKING(if _XPG4_2 is helpful) +AC_CACHE_VAL(ac_cv_xpg4_2, + [AC_TRY_LINK([#include ], + [int i=CMSG_DATA(0)], + [ac_cv_xpg4_2=no], + [AC_TRY_LINK([#define _XPG4_2 1 +#include ], + [int i=CMSG_DATA(0)], + [ac_cv_xpg4_2=yes], + [ac_cv_xpg4_2=no] + )] +)]) +if test $ac_cv_xpg4_2 = yes; then + AC_DEFINE(_XPG4_2) +fi +AC_MSG_RESULT($ac_cv_xpg4_2) + +# When on Openindiana _XPG4_2 is defined (see above) +# we also need to define __EXTENSIONS__ for basic stuff. +# Note that is important on Openindiana +# but does not exist on Linux +if test "$ac_cv_xpg4_2" = yes; then + AC_MSG_CHECKING(if __EXTENSIONS__ is helpful) + AC_CACHE_VAL(ac_cv___extensions__, + [AC_TRY_COMPILE([#include ], + [procset_t *s=0;], + [ac_cv___extensions__=no], + [AC_TRY_COMPILE([#define __EXTENSIONS__ 1 +#include ], + [procset_t *s=0;], + [ac_cv___extensions__=yes], + [ac_cv___extensions__=no] + )] + )]) + if test $ac_cv___extensions__ = yes; then + AC_DEFINE(__EXTENSIONS__) + fi + AC_MSG_RESULT($ac_cv___extensions__) +fi + +# When on Openindiana __EXTENSIONS__ is defined (see above) +# _POSIX_PTHREAD_SEMANTICS must be defined for standard ctime_r() +if test "$ac_cv___extensions__" = yes; then + AC_MSG_CHECKING(if _POSIX_PTHREAD_SEMANTICS is helpful) + AC_CACHE_VAL(ac_cv__posix_pthread_semantics, + [AC_TRY_COMPILE([#include ], + [char *s = ctime_r(0,0);], + [ac_cv__posix_pthread_semantics=no], + [AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS 1 +#include ], + [char *s = ctime_r(0,0);], + [ac_cv__posix_pthread_semantics=yes], + [ac_cv__posix_pthread_semantics=no] + )] + )]) + if test $ac_cv__posix_pthread_semantics = yes; then + AC_DEFINE(_POSIX_PTHREAD_SEMANTICS) + fi + AC_MSG_RESULT($ac_cv__posix_pthread_semantics) +fi + + # struct timespec AC_MSG_CHECKING(for struct timespec) AC_CACHE_VAL(sc_cv_struct_timespec, diff --git a/error.c b/error.c index a037245..aee61c3 100644 --- a/error.c +++ b/error.c @@ -247,7 +247,11 @@ void msg(int level, const char *format, ...) { diag_dgram.exitcode = diagopts.exitstatus; vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap); if (diag_in_handler) { - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, MSG_DONTWAIT|MSG_NOSIGNAL); + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN + strlen(diag_dgram.text)+1, MSG_DONTWAIT +#ifdef MSG_NOSIGNAL + |MSG_NOSIGNAL +#endif + ); diag_msg_avail = 1; va_end(ap); return; @@ -409,7 +413,11 @@ void diag_exit(int status) { if (diag_in_handler && !diag_immediate_exit) { diag_dgram.op = DIAG_OP_EXIT; diag_dgram.exitcode = status; - send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, MSG_DONTWAIT|MSG_NOSIGNAL); + send(diag_sock_send, &diag_dgram, sizeof(diag_dgram)-TEXTLEN, MSG_DONTWAIT +#ifdef MSG_NOSIGNAL + |MSG_NOSIGNAL +#endif + ); return; } _diag_exit(status); diff --git a/test.sh b/test.sh index 212b507..e62dbad 100755 --- a/test.sh +++ b/test.sh @@ -3760,7 +3760,9 @@ da="test$N $(date) $RANDOM" CMD="$TRACE $SOCAT -u $opts - open:$ff,append,o-trunc" printf "test $F_n $TEST... " $N rm -f $ff; $ECHO "prefix-\c" >$ff -if ! echo "$da" |$CMD >$tf 2>"$te" || +echo "$da" |$CMD >$tf 2>"$te" +rc0=$? +if ! [ $rc0 = 0 ] || ! echo "$da" |diff - $ff >"$tdiff"; then $PRINTF "$FAILED: $TRACE $SOCAT:\n" echo "$CMD" @@ -9965,21 +9967,21 @@ if [ "$rc1" -ne 0 ]; then numCANT=$((numCANT+1)) elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=" ${te}0 >/dev/null; then $PRINTF "$FAILED\n" + echo "variable $SCM_TYPE: $SCM_NAME not set" echo "$CMD0 &" echo "$CMD1" grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}1" - echo "variable $SCM_TYPE: $SCM_NAME not set" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=$SCM_VALUE" ${te}0 >/dev/null; then $PRINTF "$FAILED\n" + badval="$(grep "ancillary message: $SCM_TYPE: $SCM_NAME" ${te}0 |sed 's/.*=//g')" + echo "variable $SCM_TYPE: $SCM_NAME has value \"$badval\" instead of pattern \"$SCM_VALUE\"" >&2 echo "$CMD0 &" echo "$CMD1" grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}1" - badval="$(grep "ancillary message: $SCM_TYPE: $SCM_NAME" ${te}0 |sed 's/.*=//g')" - echo "variable $SCM_TYPE: $SCM_NAME has value \"$badval\" instead of \"$SCM_VALUE\"" numFAIL=$((numFAIL+1)) listFAIL="$listFAIL $N" else diff --git a/xio-listen.c b/xio-listen.c index a105dd8..0d9f42b 100644 --- a/xio-listen.c +++ b/xio-listen.c @@ -336,7 +336,9 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl while (maxchildren) { if (num_child < maxchildren) break; Notice("maxchildren are active, waiting"); - while (!Sleep(UINT_MAX)) ; /* any signal lets us continue */ + /* UINT_MAX would even be nicer, but Openindiana works only + with 31 bits */ + while (!Sleep(INT_MAX)) ; /* any signal lets us continue */ } Info("still listening"); } else {