mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Option so-reuseport did not work
This commit is contained in:
parent
2ea6da3839
commit
35a7817e48
4 changed files with 61 additions and 31 deletions
5
CHANGES
5
CHANGES
|
@ -17,6 +17,11 @@ corrections:
|
||||||
Option so-reuseport did not work. Thanks to Some Raghavendra Prabhu
|
Option so-reuseport did not work. Thanks to Some Raghavendra Prabhu
|
||||||
for sending a patch.
|
for sending a patch.
|
||||||
|
|
||||||
|
Programs invoked with EXEC, nofork, and -u or -U had stdin and stdout
|
||||||
|
incorrectly assigned
|
||||||
|
Test: EXEC_NOFORK_UNIDIR
|
||||||
|
Thanks to David Reiss for reporting this problem.
|
||||||
|
|
||||||
porting:
|
porting:
|
||||||
Type conflict between int and sig_atomic_t between declaration and
|
Type conflict between int and sig_atomic_t between declaration and
|
||||||
definition of diag_immediate_type and diag_immediate_exit broke
|
definition of diag_immediate_type and diag_immediate_exit broke
|
||||||
|
|
33
test.sh
33
test.sh
|
@ -12383,6 +12383,39 @@ fi # NUMCOND, SO_REUSEPORT
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
PORT=$((PORT+1))
|
PORT=$((PORT+1))
|
||||||
|
|
||||||
|
|
||||||
|
# Programs invoked with EXEC, nofork, and -u or -U had stdin and stdout assignment swapped.
|
||||||
|
NAME=EXEC_NOFORK_UNIDIR
|
||||||
|
case "$TESTS" in
|
||||||
|
*%$N%*|*%functions%*|*%bugs%*|*%exec%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: Programs invoked with EXEC, nofork, and -u or -U had stdin and stdout assignment swapped"
|
||||||
|
# invoke a simple echo command with EXEC, nofork, and -u
|
||||||
|
# expected behaviour: output appears on stdout
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
tf="$td/test$N.stdout"
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
tdiff="$td/test$N.diff"
|
||||||
|
da="test$N $(date) $RANDOM"
|
||||||
|
CMD0="$TRACE $SOCAT $opts -u /dev/null EXEC:\"echo \\\"$da\\\"\",nofork"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
eval $CMD0 >"${tf}0" 2>"${te}0"
|
||||||
|
rc1=$?
|
||||||
|
if echo "$da" |diff - "${tf}0" >"$tdiff"; then
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
echo "$CMD0"
|
||||||
|
cat "${te}0"
|
||||||
|
cat "$tdiff"
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
listFAIL="$listFAIL $N"
|
||||||
|
fi
|
||||||
|
fi # NUMCOND
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
#PORT=$((PORT+1))
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -168,40 +168,32 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* remember: fdin is the fs where the sub program reads from, thus it is
|
||||||
|
sock0[]'s read fd */
|
||||||
/*! problem: when fdi==WRFD(sock[0]) or fdo==RDFD(sock[0]) */
|
/*! problem: when fdi==WRFD(sock[0]) or fdo==RDFD(sock[0]) */
|
||||||
if (rw != XIO_WRONLY) {
|
if (rw != XIO_WRONLY) {
|
||||||
if (XIO_GETRDFD(sock[0]/*!!*/) == fdi) {
|
if (XIO_GETWRFD(sock[0]/*!!*/) == fdo) {
|
||||||
if (Fcntl_l(fdi, F_SETFD, 0) < 0) {
|
|
||||||
Warn2("fcntl(%d, F_SETFD, 0): %s", fdi, strerror(errno));
|
|
||||||
}
|
|
||||||
if (Dup2(XIO_GETRDFD(sock[0]), fdi) < 0) {
|
|
||||||
Error3("dup2(%d, %d): %s",
|
|
||||||
XIO_GETRDFD(sock[0]), fdi, strerror(errno));
|
|
||||||
}
|
|
||||||
/*0 Info2("dup2(%d, %d)", XIO_GETRDFD(sock[0]), fdi);*/
|
|
||||||
} else {
|
|
||||||
if (Dup2(XIO_GETRDFD(sock[0]), fdi) < 0) {
|
|
||||||
Error3("dup2(%d, %d): %s",
|
|
||||||
XIO_GETRDFD(sock[0]), fdi, strerror(errno));
|
|
||||||
}
|
|
||||||
/*0 Info2("dup2(%d, %d)", XIO_GETRDFD(sock[0]), fdi);*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rw != XIO_RDONLY) {
|
|
||||||
if (XIO_GETWRFD(sock[0]) == fdo) {
|
|
||||||
if (Fcntl_l(fdo, F_SETFD, 0) < 0) {
|
if (Fcntl_l(fdo, F_SETFD, 0) < 0) {
|
||||||
Warn2("fcntl(%d, F_SETFD, 0): %s", fdo, strerror(errno));
|
Warn2("fcntl(%d, F_SETFD, 0): %s", fdo, strerror(errno));
|
||||||
}
|
}
|
||||||
if (Dup2(XIO_GETWRFD(sock[0]), fdo) < 0) {
|
|
||||||
Error3("dup2(%d, %d): %s)",
|
|
||||||
XIO_GETWRFD(sock[0]), fdo, strerror(errno));
|
|
||||||
}
|
|
||||||
/*0 Info2("dup2(%d, %d)", XIO_GETWRFD(sock[0]), fdo);*/
|
|
||||||
} else {
|
} else {
|
||||||
if (Dup2(XIO_GETWRFD(sock[0]), fdo) < 0) {
|
if (Dup2(XIO_GETWRFD(sock[0]), fdo) < 0) {
|
||||||
Error3("dup2(%d, %d): %s)",
|
Error3("dup2(%d, %d): %s",
|
||||||
XIO_GETWRFD(sock[0]), fdo, strerror(errno));
|
XIO_GETWRFD(sock[0]), fdo, strerror(errno));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
/*0 Info2("dup2(%d, %d)", XIO_GETRDFD(sock[0]), fdi);*/
|
||||||
|
}
|
||||||
|
if (rw != XIO_RDONLY) {
|
||||||
|
if (XIO_GETRDFD(sock[0]) == fdi) {
|
||||||
|
if (Fcntl_l(fdi, F_SETFD, 0) < 0) {
|
||||||
|
Warn2("fcntl(%d, F_SETFD, 0): %s", fdi, strerror(errno));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (Dup2(XIO_GETRDFD(sock[0]), fdi) < 0) {
|
||||||
|
Error3("dup2(%d, %d): %s)",
|
||||||
|
XIO_GETRDFD(sock[0]), fdi, strerror(errno));
|
||||||
|
}
|
||||||
/*0 Info2("dup2(%d, %d)", XIO_GETWRFD(sock[0]), fdo);*/
|
/*0 Info2("dup2(%d, %d)", XIO_GETWRFD(sock[0]), fdo);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
12
xioopen.c
12
xioopen.c
|
@ -352,12 +352,6 @@ static xiofile_t *xioallocfd(void) {
|
||||||
/* fd->stream.para.exec.pid = 0; */
|
/* fd->stream.para.exec.pid = 0; */
|
||||||
fd->stream.lineterm = LINETERM_RAW;
|
fd->stream.lineterm = LINETERM_RAW;
|
||||||
|
|
||||||
/*!! support n socks */
|
|
||||||
if (!sock[0]) {
|
|
||||||
sock[0] = fd;
|
|
||||||
} else {
|
|
||||||
sock[1] = fd;
|
|
||||||
}
|
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,6 +370,12 @@ xiofile_t *xioopen(const char *addr, /* address specification */
|
||||||
if ((xfd = xioparse_dual(&addr)) == NULL) {
|
if ((xfd = xioparse_dual(&addr)) == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
/*!! support n socks */
|
||||||
|
if (!sock[0]) {
|
||||||
|
sock[0] = xfd;
|
||||||
|
} else {
|
||||||
|
sock[1] = xfd;
|
||||||
|
}
|
||||||
if (xioopen_dual(xfd, xioflags) < 0) {
|
if (xioopen_dual(xfd, xioflags) < 0) {
|
||||||
/*!!! free something? */
|
/*!!! free something? */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in a new issue