mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 07:22:34 +00:00
Fixed the end-close option, it just did not work
This commit is contained in:
parent
e610b14470
commit
d605ab57f5
18 changed files with 66 additions and 30 deletions
2
CHANGES
2
CHANGES
|
@ -210,6 +210,8 @@ Corrections:
|
|||
automatically spawning new connections, however the max-children option
|
||||
was not applied.
|
||||
|
||||
Fixed the end-close option, it just did not work.
|
||||
|
||||
Coding:
|
||||
Introduced groups_t instead of uint32_t, for more flexibility.
|
||||
|
||||
|
|
|
@ -111,7 +111,8 @@ static int xioopen_accept_fd(
|
|||
int xioopen_fd(struct opt *opts, int rw, struct single *sfd, int numfd) {
|
||||
|
||||
sfd->fd = numfd;
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
|
||||
#if WITH_TERMIOS
|
||||
if (Isatty(sfd->fd)) {
|
||||
|
|
|
@ -74,7 +74,8 @@ int _xioopen_interface(const char *ifname,
|
|||
ifidx = 0; /* desparate attempt to continue */
|
||||
}
|
||||
|
||||
sfd->howtoend = END_INTERFACE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_INTERFACE;
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
|
||||
retropt_socket_pf(opts, &pf);
|
||||
|
|
|
@ -54,7 +54,8 @@ int xioopen_ipapp_connect(
|
|||
}
|
||||
|
||||
xioinit_ip(&pf, xioparms.default_ip);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
return -1;
|
||||
|
@ -367,7 +368,8 @@ int xioopen_ipapp_listen(
|
|||
#endif
|
||||
}
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
|
|
|
@ -275,7 +275,8 @@ static int xioopen_openssl_connect(
|
|||
}
|
||||
|
||||
xioinit_ip(&pf, xioparms.default_ip);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
return -1;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
|
@ -592,7 +593,8 @@ static int xioopen_openssl_listen(
|
|||
|
||||
portname = argv[1];
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ static int xioopen_posixmq(
|
|||
_posixmq_unlink(sfd->para.posixmq.name, E_INFO);
|
||||
}
|
||||
retropt_bool(opts, OPT_UNLINK_CLOSE, &sfd->opt_unlink_close);
|
||||
sfd->howtoend = END_CLOSE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_CLOSE;
|
||||
sfd->dtype = XIODATA_POSIXMQ | oneshot;
|
||||
|
||||
oflag = O_CREAT;
|
||||
|
|
|
@ -113,7 +113,8 @@ static int xioopen_proxy_connect(
|
|||
targetname = argv[2];
|
||||
targetport = argv[3];
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
return -1;
|
||||
applyopts(sfd, 1, opts, PH_INIT);
|
||||
|
|
|
@ -60,7 +60,8 @@ static int xioopen_pty(
|
|||
return STAT_NORETRY;
|
||||
}
|
||||
|
||||
sfd->howtoend = END_CLOSE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_CLOSE;
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
|
|
|
@ -106,7 +106,8 @@ int _xioopen_rawip_sendto(const char *hostname, const char *protname,
|
|||
/*return STAT_NORETRY;*/
|
||||
}
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
retropt_int(opts, OPT_PROTOCOL_FAMILY, pf);
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
|
@ -228,7 +229,8 @@ static int xioopen_rawip_recvfrom(
|
|||
protname);
|
||||
/*return STAT_NORETRY;*/
|
||||
}
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
|
||||
retropt_socket_pf(opts, &pf);
|
||||
if (pf == PF_UNSPEC) {
|
||||
|
|
|
@ -75,7 +75,8 @@ static int xioopen_readline(
|
|||
Notice(msgbuf);
|
||||
|
||||
xfd->stream.fd = 0; /* stdin */
|
||||
xfd->stream.howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
xfd->stream.howtoend = END_NONE;
|
||||
xfd->stream.dtype = XIODATA_READLINE;
|
||||
|
||||
#if WITH_TERMIOS
|
||||
|
|
18
xio-socket.c
18
xio-socket.c
|
@ -236,7 +236,8 @@ static int xioopen_socket_connect(
|
|||
retropt_socket_pf(opts, &pf);
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
return -1;
|
||||
|
@ -320,7 +321,8 @@ static int xioopen_socket_listen(
|
|||
retropt_socket_pf(opts, &pf);
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
socket_init(0, &us);
|
||||
ussize = 0;
|
||||
|
@ -415,7 +417,8 @@ int _xioopen_socket_sendto(const char *pfname, const char *type,
|
|||
retropt_socket_pf(opts, &pf);
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
sfd->peersa.soa.sa_family = pf;
|
||||
themsize = 0;
|
||||
|
@ -516,7 +519,8 @@ int xioopen_socket_recvfrom(
|
|||
retropt_socket_pf(opts, &pf);
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
|
||||
ussize = 0;
|
||||
if ((result =
|
||||
|
@ -600,7 +604,8 @@ int xioopen_socket_recv(
|
|||
retropt_socket_pf(opts, &pf);
|
||||
retropt_int(opts, OPT_SO_TYPE, &socktype);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
|
||||
ussize = 0;
|
||||
if ((result =
|
||||
|
@ -673,7 +678,8 @@ static int xioopen_socket_datagram(
|
|||
|
||||
retropt_socket_pf(opts, &pf);
|
||||
/*retropt_int(opts, OPT_IP_PROTOCOL, &proto);*/
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
sfd->peersa.soa.sa_family = pf;
|
||||
themsize = 0;
|
||||
|
|
|
@ -76,7 +76,8 @@ static int xioopen_socks4_connect(
|
|||
targetname = argv[2];
|
||||
targetport = argv[3];
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
applyopts(sfd, 1, opts, PH_INIT);
|
||||
|
||||
|
|
|
@ -531,7 +531,8 @@ static int xioopen_socks5(
|
|||
target_name = argv[3];
|
||||
target_port = argv[4];
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return -1;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
|
||||
|
|
|
@ -41,7 +41,9 @@ int xioopen_stdio_bi(xiofile_t *sock) {
|
|||
sock->dual.stream[0]->fd = 0 /*stdin*/;
|
||||
sock->dual.stream[1]->tag = XIO_TAG_WRONLY;
|
||||
sock->dual.stream[1]->fd = 1 /*stdout*/;
|
||||
sock->dual.stream[0]->howtoend =
|
||||
if (sock->dual.stream[0]->howtoend == END_UNSPEC)
|
||||
sock->dual.stream[0]->howtoend = END_NONE;
|
||||
if (sock->dual.stream[1]->howtoend == END_UNSPEC)
|
||||
sock->dual.stream[1]->howtoend = END_NONE;
|
||||
|
||||
#if WITH_TERMIOS
|
||||
|
|
|
@ -260,7 +260,8 @@ int _xioopen_ipdgram_listen(struct single *sfd,
|
|||
xiosetsockaddrenv("SOCK", us, uslen, IPPROTO_UDP);
|
||||
xiosetsockaddrenv("PEER", them, themlen, IPPROTO_UDP);
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
applyopts_fchown(sfd->fd, opts);
|
||||
applyopts(sfd, -1, opts, PH_LATE);
|
||||
|
||||
|
@ -383,7 +384,8 @@ int _xioopen_udp_sendto(const char *hostname, const char *servname,
|
|||
bool needbind = false;
|
||||
int result;
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
/* ...res_opts[] */
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
|
@ -539,6 +541,8 @@ static int xioopen_udp_recvfrom(
|
|||
|
||||
xioinit_ip(&pf, xioparms.default_ip);
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
if (pf == PF_UNSPEC) {
|
||||
#if WITH_IP4 && WITH_IP6
|
||||
|
|
18
xio-unix.c
18
xio-unix.c
|
@ -142,7 +142,8 @@ static int xioopen_unix_listen(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
if (!(ABSTRACT && addrdesc->arg1/*abstract*/)) {
|
||||
/* only for non abstract because abstract do not work in file system */
|
||||
|
@ -239,7 +240,8 @@ static int xioopen_unix_connect(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return STAT_NORETRY;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
applyopts_offset(sfd, opts);
|
||||
|
@ -409,7 +411,8 @@ static int xioopen_unix_sendto(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
applyopts_offset(sfd, opts);
|
||||
|
||||
sfd->salen = xiosetunix(pf, &sfd->peersa.un, name, addrdesc->arg1/*abstract*/, sfd->para.socket.un.tight);
|
||||
|
@ -494,7 +497,8 @@ int xioopen_unix_recvfrom(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_NONE;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_NONE;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return STAT_NORETRY;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
applyopts_named(name, opts, PH_EARLY); /* umask! */
|
||||
|
@ -580,7 +584,8 @@ static int xioopen_unix_recv(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return STAT_NORETRY;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
applyopts_named(name, opts, PH_EARLY); /* umask! */
|
||||
|
@ -687,7 +692,8 @@ _xioopen_unix_client(
|
|||
|
||||
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
|
||||
retropt_socket_pf(opts, &pf);
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0) return STAT_NORETRY;
|
||||
applyopts(sfd, -1, opts, PH_INIT);
|
||||
applyopts_offset(sfd, opts);
|
||||
|
|
|
@ -43,7 +43,8 @@ static int vsock_addr_init(struct sockaddr_vm *sa, const char *cid_str,
|
|||
/* Performs a few steps during opening an address of type VSOCK */
|
||||
static int vsock_init(struct opt *opts, struct single *sfd) {
|
||||
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
if (sfd->howtoend == END_UNSPEC)
|
||||
sfd->howtoend = END_SHUTDOWN;
|
||||
|
||||
if (applyopts_single(sfd, opts, PH_INIT) < 0)
|
||||
return STAT_NORETRY;
|
||||
|
|
|
@ -79,6 +79,7 @@ int xioshutdown(xiofile_t *sock, int how) {
|
|||
#endif /* _WITH_SOCKET */
|
||||
default: ;
|
||||
}
|
||||
/* XIOSHUT_UNSPEC passes on */
|
||||
|
||||
if (false) {
|
||||
;
|
||||
|
|
Loading…
Reference in a new issue