Fix error message on UI when testing Opossum

As `wait_kill()` returns with 0 when a TCP reset is encountered
and the process is not killed, we need to open the socket again
in a sub shell. Which is safe in the foreground.

If then the subshell returns with 0 we can safely connect to
port 80.
This commit is contained in:
Dirk Wetter 2025-07-20 15:40:35 +02:00
parent ea3cc3789f
commit e09d79aad9

View File

@ -1942,6 +1942,10 @@ http_head_printf() {
# This is a subshell, so fd 8 is not inherited
bash -c "exec 8<>/dev/tcp/$node/80" 2>/dev/null &
wait_kill $! $HEADER_MAXSLEEP
if [[ $? -ne 3 ]]; then
# process with pid !$ wasn't killed but was that a reject? So we try again
# to make sure there wasn't a TCP reset
bash -c "exec 8<>/dev/tcp/$node/80" 2>/dev/null
if [[ $? -eq 0 ]]; then
exec 33<>/dev/tcp/$node/80
# not killed --> socket open. Now we connect to the virtual host "$node"
@ -1962,6 +1966,7 @@ http_head_printf() {
fi
exec 33<&-
exec 33>&-
fi
return $ret
}