mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
under some circumstances shutdown was called multiple times for the same fd
This commit is contained in:
parent
634e02269f
commit
5999bbc1b8
3 changed files with 33 additions and 26 deletions
3
CHANGES
3
CHANGES
|
@ -2,6 +2,9 @@
|
||||||
corrections:
|
corrections:
|
||||||
help displayed some option types wrong
|
help displayed some option types wrong
|
||||||
|
|
||||||
|
under some circumstances shutdown was called multiple times for the
|
||||||
|
same fd
|
||||||
|
|
||||||
####################### V 1.7.0.0:
|
####################### V 1.7.0.0:
|
||||||
|
|
||||||
new features:
|
new features:
|
||||||
|
|
16
socat.c
16
socat.c
|
@ -1045,14 +1045,16 @@ int _socat(void) {
|
||||||
xioshutdown(sock2, SHUT_WR);
|
xioshutdown(sock2, SHUT_WR);
|
||||||
XIO_RDSTREAM(sock1)->eof = 2;
|
XIO_RDSTREAM(sock1)->eof = 2;
|
||||||
XIO_RDSTREAM(sock1)->ignoreeof = false;
|
XIO_RDSTREAM(sock1)->ignoreeof = false;
|
||||||
|
}
|
||||||
|
} else if (polling && XIO_RDSTREAM(sock1)->ignoreeof) {
|
||||||
|
polling = 0;
|
||||||
|
}
|
||||||
|
if (XIO_RDSTREAM(sock1)->eof >= 2) {
|
||||||
if (socat_opts.lefttoright) {
|
if (socat_opts.lefttoright) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
closing = 1;
|
closing = 1;
|
||||||
}
|
}
|
||||||
} else if (polling && XIO_RDSTREAM(sock1)->ignoreeof) {
|
|
||||||
polling = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bytes2 == 0 || XIO_RDSTREAM(sock2)->eof >= 2) {
|
if (bytes2 == 0 || XIO_RDSTREAM(sock2)->eof >= 2) {
|
||||||
if (XIO_RDSTREAM(sock2)->ignoreeof &&
|
if (XIO_RDSTREAM(sock2)->ignoreeof &&
|
||||||
|
@ -1066,14 +1068,16 @@ int _socat(void) {
|
||||||
xioshutdown(sock1, SHUT_WR);
|
xioshutdown(sock1, SHUT_WR);
|
||||||
XIO_RDSTREAM(sock2)->eof = 2;
|
XIO_RDSTREAM(sock2)->eof = 2;
|
||||||
XIO_RDSTREAM(sock2)->ignoreeof = false;
|
XIO_RDSTREAM(sock2)->ignoreeof = false;
|
||||||
|
}
|
||||||
|
} else if (polling && XIO_RDSTREAM(sock2)->ignoreeof) {
|
||||||
|
polling = 0;
|
||||||
|
}
|
||||||
|
if (XIO_RDSTREAM(sock2)->eof >= 2) {
|
||||||
if (socat_opts.righttoleft) {
|
if (socat_opts.righttoleft) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
closing = 1;
|
closing = 1;
|
||||||
}
|
}
|
||||||
} else if (polling && XIO_RDSTREAM(sock2)->ignoreeof) {
|
|
||||||
polling = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* close everything that's still open */
|
/* close everything that's still open */
|
||||||
|
|
36
test.sh
36
test.sh
|
@ -2149,7 +2149,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=FILE
|
NAME=FILE
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%file%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%file%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: simple echo via file"
|
TEST="$NAME: simple echo via file"
|
||||||
tf="$td/file$N"
|
tf="$td/file$N"
|
||||||
testecho "$N" "$TEST" "" "$tf,ignoreeof!!$tf" "$opts"
|
testecho "$N" "$TEST" "" "$tf,ignoreeof!!$tf" "$opts"
|
||||||
|
@ -3185,7 +3185,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=GOPENFILE
|
NAME=GOPENFILE
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%gopen%*|*%file%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%gopen%*|*%file%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: file opening with gopen"
|
TEST="$NAME: file opening with gopen"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
tf1="$td/test$N.1.stdout"
|
tf1="$td/test$N.1.stdout"
|
||||||
|
@ -3364,7 +3364,7 @@ N=$((N+1))
|
||||||
#set -vx
|
#set -vx
|
||||||
NAME=IGNOREEOF
|
NAME=IGNOREEOF
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: ignoreeof on file"
|
TEST="$NAME: ignoreeof on file"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
ti="$td/test$N.file"
|
ti="$td/test$N.file"
|
||||||
|
@ -3399,7 +3399,7 @@ set +vx
|
||||||
|
|
||||||
NAME=EXECIGNOREEOF
|
NAME=EXECIGNOREEOF
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: exec against address with ignoreeof"
|
TEST="$NAME: exec against address with ignoreeof"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
tf="$td/test$N.stdout"
|
tf="$td/test$N.stdout"
|
||||||
|
@ -4334,7 +4334,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=TOTALTIMEOUT
|
NAME=TOTALTIMEOUT
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%timeout%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%timeout%*|*%$NAME%*)
|
||||||
TEST="$NAME: socat inactivity timeout"
|
TEST="$NAME: socat inactivity timeout"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
#set -vx
|
#set -vx
|
||||||
|
@ -4373,7 +4373,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=IGNOREEOF+TOTALTIMEOUT
|
NAME=IGNOREEOF+TOTALTIMEOUT
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%timeout%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%timeout%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: ignoreeof and inactivity timeout"
|
TEST="$NAME: ignoreeof and inactivity timeout"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
#set -vx
|
#set -vx
|
||||||
|
@ -4412,7 +4412,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=PROXY2SPACES
|
NAME=PROXY2SPACES
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%$NAME%*)
|
*%functions%*|*%proxy%*|*%$NAME%*)
|
||||||
TEST="$NAME: proxy connect accepts status with multiple spaces"
|
TEST="$NAME: proxy connect accepts status with multiple spaces"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! testaddrs proxy >/dev/null; then
|
elif ! testaddrs proxy >/dev/null; then
|
||||||
|
@ -4707,7 +4707,7 @@ N=$((N+1))
|
||||||
#!
|
#!
|
||||||
NAME=OUTBOUNDIN
|
NAME=OUTBOUNDIN
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%$NAME%*)
|
*%functions%*|*%proxy%*|*%$NAME%*)
|
||||||
TEST="$NAME: gender changer via SSL through HTTP proxy, oneshot"
|
TEST="$NAME: gender changer via SSL through HTTP proxy, oneshot"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! feat=$(testaddrs openssl proxy); then
|
elif ! feat=$(testaddrs openssl proxy); then
|
||||||
|
@ -4792,7 +4792,7 @@ PORT=$((RANDOM+16184))
|
||||||
#!
|
#!
|
||||||
NAME=INTRANETRIPPER
|
NAME=INTRANETRIPPER
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%$NAME%*)
|
*%functions%*|*%proxy%*|*%$NAME%*)
|
||||||
TEST="$NAME: gender changer via SSL through HTTP proxy, daemons"
|
TEST="$NAME: gender changer via SSL through HTTP proxy, daemons"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! feat=$(testaddrs openssl proxy); then
|
elif ! feat=$(testaddrs openssl proxy); then
|
||||||
|
@ -5995,7 +5995,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=UNIXTODGRAM
|
NAME=UNIXTODGRAM
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%unix%*|*%recv%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%unix%*|*%recv%*|*%$NAME%*)
|
||||||
TEST="$NAME: generic UNIX client connects to datagram socket"
|
TEST="$NAME: generic UNIX client connects to datagram socket"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
ts1="$td/test$N.socket1"
|
ts1="$td/test$N.socket1"
|
||||||
|
@ -6377,7 +6377,7 @@ fi #false
|
||||||
|
|
||||||
NAME=UNIXDGRAM
|
NAME=UNIXDGRAM
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%unix%*|*%dgram%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%unix%*|*%dgram%*|*%$NAME%*)
|
||||||
TEST="$NAME: UNIX datagram"
|
TEST="$NAME: UNIX datagram"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
tf="$td/test$N.stdout"
|
tf="$td/test$N.stdout"
|
||||||
|
@ -6419,7 +6419,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=UDP4RECV
|
NAME=UDP4RECV
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%ip4%*|*%dgram%*|*%udp%*|*%udp4%*|*%recv%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%ip4%*|*%dgram%*|*%udp%*|*%udp4%*|*%recv%*|*%$NAME%*)
|
||||||
TEST="$NAME: UDP/IPv4 receive"
|
TEST="$NAME: UDP/IPv4 receive"
|
||||||
if ! eval $NUMCOND; then :; else
|
if ! eval $NUMCOND; then :; else
|
||||||
tf="$td/test$N.stdout"
|
tf="$td/test$N.stdout"
|
||||||
|
@ -7304,7 +7304,7 @@ N=$((N+1))
|
||||||
|
|
||||||
NAME=COOLWRITE
|
NAME=COOLWRITE
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*)
|
||||||
TEST="$NAME: option cool-write"
|
TEST="$NAME: option cool-write"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! testoptions cool-write >/dev/null; then
|
elif ! testoptions cool-write >/dev/null; then
|
||||||
|
@ -7346,7 +7346,7 @@ N=$((N+1))
|
||||||
# this failed up to socat 1.6.0.0
|
# this failed up to socat 1.6.0.0
|
||||||
NAME=COOLSTDIO
|
NAME=COOLSTDIO
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*)
|
||||||
TEST="$NAME: option cool-write on bidirectional stdio"
|
TEST="$NAME: option cool-write on bidirectional stdio"
|
||||||
# this test starts a socat reader that terminates after receiving one+
|
# this test starts a socat reader that terminates after receiving one+
|
||||||
# bytes (option readbytes); and a test process that sends two bytes via
|
# bytes (option readbytes); and a test process that sends two bytes via
|
||||||
|
@ -7682,7 +7682,7 @@ NAME=IP4BROADCAST
|
||||||
# because we receive - in addition to the regular reply - our own broadcast,
|
# because we receive - in addition to the regular reply - our own broadcast,
|
||||||
# we use a token XXXX that is changed to YYYY in the regular reply packet.
|
# we use a token XXXX that is changed to YYYY in the regular reply packet.
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%rawip%*|*%rawip4%*|*%ip4%*|*%dgram%*|*%broadcast%*|*%root%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%rawip%*|*%rawip4%*|*%ip4%*|*%dgram%*|*%broadcast%*|*%root%*|*%$NAME%*)
|
||||||
TEST="$NAME: raw IPv4 broadcast"
|
TEST="$NAME: raw IPv4 broadcast"
|
||||||
if ! eval $NUMCOND; then :;
|
if ! eval $NUMCOND; then :;
|
||||||
elif ! feat=$(testaddrs ip4 rawip) || ! runsip4 >/dev/null; then
|
elif ! feat=$(testaddrs ip4 rawip) || ! runsip4 >/dev/null; then
|
||||||
|
@ -8809,7 +8809,7 @@ N=$((N+1))
|
||||||
# the reverse direction
|
# the reverse direction
|
||||||
NAME=IGNOREEOFNOBLOCK
|
NAME=IGNOREEOFNOBLOCK
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%socket%*|*%ignoreeof%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%socket%*|*%ignoreeof%*|*%$NAME%*)
|
||||||
TEST="$NAME: ignoreeof does not block other direction"
|
TEST="$NAME: ignoreeof does not block other direction"
|
||||||
# have socat poll in ignoreeof mode. while it waits one second for next check,
|
# have socat poll in ignoreeof mode. while it waits one second for next check,
|
||||||
# we send data in the reverse direction and then the total timeout fires.
|
# we send data in the reverse direction and then the total timeout fires.
|
||||||
|
@ -8848,7 +8848,7 @@ N=$((N+1))
|
||||||
# test the escape option
|
# test the escape option
|
||||||
NAME=ESCAPE
|
NAME=ESCAPE
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%escape%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%escape%*|*%$NAME%*)
|
||||||
TEST="$NAME: escape character triggers EOF"
|
TEST="$NAME: escape character triggers EOF"
|
||||||
# idea: start socat just echoing input, but apply escape option. send a string
|
# idea: start socat just echoing input, but apply escape option. send a string
|
||||||
# containing the escape character and check if the output is truncated
|
# containing the escape character and check if the output is truncated
|
||||||
|
@ -8881,7 +8881,7 @@ N=$((N+1))
|
||||||
# test the escape option combined with ignoreeof
|
# test the escape option combined with ignoreeof
|
||||||
NAME=ESCAPE_IGNOREEOF
|
NAME=ESCAPE_IGNOREEOF
|
||||||
case "$TESTS" in
|
case "$TESTS" in
|
||||||
*%functions%*|*%ignoreeof%*|*%escape%*|*%$NAME%*)
|
*%functions%*|*%engine%*|*%ignoreeof%*|*%escape%*|*%$NAME%*)
|
||||||
TEST="$NAME: escape character triggers EOF"
|
TEST="$NAME: escape character triggers EOF"
|
||||||
# idea: start socat just echoing input, but apply escape option. send a string
|
# idea: start socat just echoing input, but apply escape option. send a string
|
||||||
# containing the escape character and check if the output is truncated
|
# containing the escape character and check if the output is truncated
|
||||||
|
|
Loading…
Reference in a new issue