halrmt: Allow IPv4 as fallback when IPv6 is disabled. - #4405
Conversation
62040e0 to
01968b7
Compare
|
|
||
| static int getSocket4(struct sockaddr_in &addr, socklen_t &slen) | ||
| { | ||
| int sockfd = socket(AF_INET, SOCK_STREAM, 0); |
There was a problem hiding this comment.
The refactor dropped SOCK_CLOEXEC | SOCK_NONBLOCK from both socket() calls here
and at line 2918. Master has them on the listen socket:
sockfd = socket(AF_INET6, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
and halrmt has no fcntl fallback anywhere, unlike emcrsh which calls
set_nonblock() after listen(). So the listener is now blocking and inheritable:
- accept4() after a spurious POLLIN blocks the poll loop indefinitely (accept(2)
BUGS: the connection can be aborted between poll and accept, leaving nothing
to take). That is the caveat from linuxcncrsh: IPv6-only listen socket fails to start when IPv6 is disabled #4401. - halrmt forks and execs at line 628, so every component it launches inherits
the listening fd and keeps port 5006 bound past halrmt's exit.
The first push had the flags on the IPv6 socket. Restoring them on both calls
should be all that is needed.
There was a problem hiding this comment.
At least you are watching. I must have been asleep. May still require some head banging ;-)
Fixed.
01968b7 to
a78ed3e
Compare
|
Flags restored, thanks. One leftover: " -4,--ipv4 Only use IPv4\n" |
a78ed3e to
0690ee3
Compare
|
Must have hurt my head ;-) Added the usage() line. |
The new halrmt server uses v4-mapped-on-v6 to have one socket accept both IPv6 and IPv4 connections. However, if IPv6 is disabled at the kernel command line (or not compiled in), then it would fail to create a listening socket. This PR adds an IPv4-only fallback in case IPv6 fails.