mirror of
https://repo.or.cz/socat.git
synced 2025-01-09 14:32:33 +00:00
merged connect-timeout bug fix
This commit is contained in:
commit
e5f2863cd8
4 changed files with 58 additions and 7 deletions
4
CHANGES
4
CHANGES
|
@ -1,5 +1,9 @@
|
||||||
|
|
||||||
corrections:
|
corrections:
|
||||||
|
fixed a bug, introduced with version 1.7.0.0, that let client
|
||||||
|
connections with option connect-timeout fail when the connections
|
||||||
|
succeeded. Thanks to Bruno De Fraine for reporting this bug.
|
||||||
|
|
||||||
half close of EXEC and SYSTEM addresses did not work for pipes and
|
half close of EXEC and SYSTEM addresses did not work for pipes and
|
||||||
sometimes socketpair
|
sometimes socketpair
|
||||||
|
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
"1.7.0.0+execshut"
|
"1.7.0.0+execshut+connecttimeout"
|
||||||
|
|
51
test.sh
51
test.sh
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
# source: test.sh
|
# source: test.sh
|
||||||
# Copyright Gerhard Rieger 2001-2008
|
# Copyright Gerhard Rieger 2001-2009
|
||||||
# Published under the GNU General Public License V.2, see file COPYING
|
# Published under the GNU General Public License V.2, see file COPYING
|
||||||
|
|
||||||
# perform lots of tests on socat
|
# perform lots of tests on socat
|
||||||
|
@ -5694,7 +5694,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=CONNECTTIMEOUT
|
NAME=CONNECTTIMEOUT
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%$NAME%*)
|
*%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%timeout%*|*%$NAME%*)
|
||||||
TEST="$NAME: test the connect-timeout option"
|
TEST="$NAME: test the connect-timeout option"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! feat=$(testaddrs tcp); then
|
elif ! feat=$(testaddrs tcp); then
|
||||||
|
@ -5745,6 +5745,53 @@ esac
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
# version 1.7.0.0 had a bug with the connect-timeout option: while it correctly
|
||||||
|
# terminated a hanging connect attempt, it prevented a successful connection
|
||||||
|
# establishment from being recognized by socat, instead the timeout occurred
|
||||||
|
NAME=CONNECTTIMEOUT_CONN
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
case "$TESTS" in
|
||||||
|
*%functions%*|*%ip4%*|*%ipapp%*|*%tcp%*|*%timeout%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: TCP4 connect-timeout option when server replies"
|
||||||
|
# just try a connection that is expected to succeed with the usual data
|
||||||
|
# transfer; with the bug it will fail
|
||||||
|
tf="$td/test$N.stdout"
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
tdiff="$td/test$N.diff"
|
||||||
|
tsl=$PORT
|
||||||
|
ts="127.0.0.1:$tsl"
|
||||||
|
da="test$N $(date) $RANDOM"
|
||||||
|
CMD1="$SOCAT $opts TCP4-LISTEN:$tsl,reuseaddr PIPE"
|
||||||
|
CMD2="$SOCAT $opts STDIO TCP4:$ts,connect-timeout=1"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
$CMD1 >"$tf" 2>"${te}1" &
|
||||||
|
pid1=$!
|
||||||
|
waittcp4port $tsl 1
|
||||||
|
echo "$da" |$CMD2 >>"$tf" 2>>"${te}2"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
$PRINTF "$FAILED: $SOCAT:\n"
|
||||||
|
echo "$CMD1 &"
|
||||||
|
cat "${te}1"
|
||||||
|
echo "$CMD2"
|
||||||
|
cat "${te}2"
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
elif ! echo "$da" |diff - "$tf" >"$tdiff"; then
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
cat "$tdiff"
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
if [ -n "$debug" ]; then cat "${te}1" "${te}2"; fi
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
fi
|
||||||
|
kill $pid1 2>/dev/null
|
||||||
|
wait ;;
|
||||||
|
esac
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
fi # NUMCOND
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
NAME=OPENSSLLISTENDSA
|
NAME=OPENSSLLISTENDSA
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%$NAME%*)
|
*%functions%*|*%$NAME%*)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* source: xio-socket.c */
|
/* source: xio-socket.c */
|
||||||
/* Copyright Gerhard Rieger 2001-2008 */
|
/* Copyright Gerhard Rieger 2001-2009 */
|
||||||
/* Published under the GNU General Public License V.2, see file COPYING */
|
/* Published under the GNU General Public License V.2, see file COPYING */
|
||||||
|
|
||||||
/* this file contains the source for socket related functions, and the
|
/* this file contains the source for socket related functions, and the
|
||||||
|
@ -849,10 +849,10 @@ int _xioopen_connect(struct single *xfd, struct sockaddr *us, size_t uslen,
|
||||||
themlen, strerror(errno));
|
themlen, strerror(errno));
|
||||||
timeout = xfd->para.socket.connect_timeout;
|
timeout = xfd->para.socket.connect_timeout;
|
||||||
writefd.fd = xfd->fd;
|
writefd.fd = xfd->fd;
|
||||||
writefd.events = (POLLIN|POLLHUP|POLLERR);
|
writefd.events = (POLLOUT|POLLERR);
|
||||||
result = xiopoll(&writefd, 1, &timeout);
|
result = xiopoll(&writefd, 1, &timeout);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
Msg4(level, "xiopoll({%d,POLLIN|POLLHUP|POLLER},,{"F_tv_sec"."F_tv_usec"): %s",
|
Msg4(level, "xiopoll({%d,POLLOUT|POLLERR},,{"F_tv_sec"."F_tv_usec"): %s",
|
||||||
xfd->fd, timeout.tv_sec, timeout.tv_usec, strerror(errno));
|
xfd->fd, timeout.tv_sec, timeout.tv_usec, strerror(errno));
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +862,7 @@ int _xioopen_connect(struct single *xfd, struct sockaddr *us, size_t uslen,
|
||||||
strerror(ETIMEDOUT));
|
strerror(ETIMEDOUT));
|
||||||
return STAT_RETRYLATER;
|
return STAT_RETRYLATER;
|
||||||
}
|
}
|
||||||
if (writefd.revents & POLLOUT) {
|
if (writefd.revents & POLLERR) {
|
||||||
#if 0
|
#if 0
|
||||||
unsigned char dummy[1];
|
unsigned char dummy[1];
|
||||||
Read(xfd->fd, &dummy, 1); /* get error message */
|
Read(xfd->fd, &dummy, 1); /* get error message */
|
||||||
|
|
Loading…
Reference in a new issue