diff --git a/CHANGES b/CHANGES index 80512b4..8bef34f 100644 --- a/CHANGES +++ b/CHANGES @@ -56,6 +56,10 @@ Corrections: Nanosleep() trace output now in decimal form. + UNIX-LISTEN with bind option terminated with INTERNAL error, this is + now handled properly. + Test: UNIX_L_BIND + Features: POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T, makes it possible to terminate Socat in case the queue is empty. diff --git a/test.sh b/test.sh index 05208ec..64e2158 100755 --- a/test.sh +++ b/test.sh @@ -19446,6 +19446,57 @@ esac N=$((N+1)) +# Test for useful error message on UNIX-L with bind option +NAME=UNIX_L_BIND +case "$TESTS" in +*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%listen%*|*%unix%*|*%bind%*|*%$NAME%*) +TEST="$NAME: Test if UNIX-L with bind does not fail INTERNAL" +# Invoke Socat with a UNIX-LISTEN address with bind option. +# When there is no INTERNAL error the test succeeded. +if ! eval $NUMCOND; then : +elif ! cond=$(checkconds \ + "" \ + "" \ + "" \ + "UNIX LISTEN PIPE" \ + "UNIX-LISTEN PIPE" \ + "bind,accept-timeout" \ + "" ); then + $PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N + cant +else + ts="$td/test$N.sock" + tb="$td/test$N.bind" + tf="$td/test$N.stdout" + te="$td/test$N.stderr" + tdiff="$td/test$N.diff" + da="test$N $(date) $RANDOM" + CMD0="$TRACE $SOCAT $opts UNIX-LISTEN:$ts,accept-timeout=0.001,bind=$tb PIPE" + printf "test $F_n $TEST... " $N + $CMD0 >/dev/null 2>"${te}0" + rc0=$? + if [ "$rc0" -eq 0 ]; then + $PRINTF "$CANT (rc0=$rc0)\n" + echo "$CMD0" + cat "${te}0" >&2 + cant + elif grep " E .* INTERNAL " "${te}0" >/dev/null; then + $PRINTF "$FAILED (INTERNAL)\n" + echo "$CMD0" + cat "${te}0" >&2 + failed + else + $PRINTF "$OK\n" + if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi + if [ "$DEBUG" ]; then cat "${te}0" >&2; fi + ok + fi +fi # NUMCOND + ;; +esac +N=$((N+1)) + + # end of common tests ################################################################################## diff --git a/xio-unix.c b/xio-unix.c index 67d2b7a..b1bc04f 100644 --- a/xio-unix.c +++ b/xio-unix.c @@ -123,6 +123,7 @@ static int xioopen_unix_listen( /* we expect the form: filename */ const char *name; xiosingle_t *sfd = &xxfd->stream; + char *bindstring = NULL; int pf = PF_UNIX; int socktype = SOCK_STREAM; int protocol = 0; @@ -140,6 +141,12 @@ static int xioopen_unix_listen( } name = argv[1]; + if (retropt_string(opts, OPT_BIND, &bindstring) == 0) { + Error2("%s:%s: binds implicitly, bind option not allowed", + addrdesc->defname, argv[1]); + free(bindstring); + } + sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN; retropt_socket_pf(opts, &pf); if (sfd->howtoend == END_UNSPEC)