Port to Openindiana

This commit is contained in:
Gerhard Rieger 2015-04-02 17:55:26 +02:00
parent 1720c9aa10
commit a0ded9f095
6 changed files with 95 additions and 8 deletions

View file

@ -338,6 +338,9 @@ porting:
Use 'environ' variable only when provided by runtime Use 'environ' variable only when provided by runtime
Changes for Openindiana: define _XPG4_2, __EXTENSIONS__,
_POSIX_PTHREAD_SEMANTICS; and minor changes
new features: new features:
added option max-children that limits the number of concurrent child added option max-children that limits the number of concurrent child
processes. Thanks to Sam Liddicott for providing the patch. processes. Thanks to Sam Liddicott for providing the patch.

View file

@ -344,6 +344,15 @@
/* Define if your termios.h likes _SVID3 defined */ /* Define if your termios.h likes _SVID3 defined */
#undef _SVID3 #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) */ /* Define if you have struct timespec (e.g. for nanosleep) */
#undef HAVE_STRUCT_TIMESPEC #undef HAVE_STRUCT_TIMESPEC

View file

@ -1043,6 +1043,69 @@ fi
AC_MSG_RESULT($ac_cv_svid3) 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 <sys/socket.h>],
[int i=CMSG_DATA(0)],
[ac_cv_xpg4_2=no],
[AC_TRY_LINK([#define _XPG4_2 1
#include <sys/socket.h>],
[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 <sys/procset.h> 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 <sys/procset.h>],
[procset_t *s=0;],
[ac_cv___extensions__=no],
[AC_TRY_COMPILE([#define __EXTENSIONS__ 1
#include <sys/procset.h>],
[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 <time.h>],
[char *s = ctime_r(0,0);],
[ac_cv__posix_pthread_semantics=no],
[AC_TRY_COMPILE([#define _POSIX_PTHREAD_SEMANTICS 1
#include <time.h>],
[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 # struct timespec
AC_MSG_CHECKING(for struct timespec) AC_MSG_CHECKING(for struct timespec)
AC_CACHE_VAL(sc_cv_struct_timespec, AC_CACHE_VAL(sc_cv_struct_timespec,

12
error.c
View file

@ -247,7 +247,11 @@ void msg(int level, const char *format, ...) {
diag_dgram.exitcode = diagopts.exitstatus; diag_dgram.exitcode = diagopts.exitstatus;
vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap); vsnprintf_r(diag_dgram.text, sizeof(diag_dgram.text), format, ap);
if (diag_in_handler) { 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; diag_msg_avail = 1;
va_end(ap); va_end(ap);
return; return;
@ -409,7 +413,11 @@ void diag_exit(int status) {
if (diag_in_handler && !diag_immediate_exit) { if (diag_in_handler && !diag_immediate_exit) {
diag_dgram.op = DIAG_OP_EXIT; diag_dgram.op = DIAG_OP_EXIT;
diag_dgram.exitcode = status; 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; return;
} }
_diag_exit(status); _diag_exit(status);

10
test.sh
View file

@ -3760,7 +3760,9 @@ da="test$N $(date) $RANDOM"
CMD="$TRACE $SOCAT -u $opts - open:$ff,append,o-trunc" CMD="$TRACE $SOCAT -u $opts - open:$ff,append,o-trunc"
printf "test $F_n $TEST... " $N printf "test $F_n $TEST... " $N
rm -f $ff; $ECHO "prefix-\c" >$ff 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 ! echo "$da" |diff - $ff >"$tdiff"; then
$PRINTF "$FAILED: $TRACE $SOCAT:\n" $PRINTF "$FAILED: $TRACE $SOCAT:\n"
echo "$CMD" echo "$CMD"
@ -9965,21 +9967,21 @@ if [ "$rc1" -ne 0 ]; then
numCANT=$((numCANT+1)) numCANT=$((numCANT+1))
elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=" ${te}0 >/dev/null; then elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=" ${te}0 >/dev/null; then
$PRINTF "$FAILED\n" $PRINTF "$FAILED\n"
echo "variable $SCM_TYPE: $SCM_NAME not set"
echo "$CMD0 &" echo "$CMD0 &"
echo "$CMD1" echo "$CMD1"
grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}0"
grep " $LEVELS " "${te}1" grep " $LEVELS " "${te}1"
echo "variable $SCM_TYPE: $SCM_NAME not set"
numFAIL=$((numFAIL+1)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=$SCM_VALUE" ${te}0 >/dev/null; then elif ! grep "ancillary message: $SCM_TYPE: $SCM_NAME=$SCM_VALUE" ${te}0 >/dev/null; then
$PRINTF "$FAILED\n" $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 "$CMD0 &"
echo "$CMD1" echo "$CMD1"
grep " $LEVELS " "${te}0" grep " $LEVELS " "${te}0"
grep " $LEVELS " "${te}1" 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)) numFAIL=$((numFAIL+1))
listFAIL="$listFAIL $N" listFAIL="$listFAIL $N"
else else

View file

@ -336,7 +336,9 @@ int _xioopen_listen(struct single *xfd, int xioflags, struct sockaddr *us, sockl
while (maxchildren) { while (maxchildren) {
if (num_child < maxchildren) break; if (num_child < maxchildren) break;
Notice("maxchildren are active, waiting"); 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"); Info("still listening");
} else { } else {