1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-09 03:06:51 +00:00

Print info on implicit SO_REUSEADDR

This commit is contained in:
Gerhard 2025-02-11 12:31:59 +01:00
parent 3339885f5b
commit e6aa3d1787
3 changed files with 12 additions and 3 deletions

View file

@ -107,6 +107,9 @@ Features:
Procan tells if char is signed or unsigned
Socat now prints an info message when implicitely setting SO_REUSEADDR.
Thanks to Michael Renner for this suggestion.
Building:
Disabling certain features during configure could break build process.

View file

@ -2327,7 +2327,7 @@ int xiobind(
Socat option so-reuseaddr:
Option not applied: set it to 1
Option applied with a value: set it to the value
Option applied eith empty value "so-reuseaddr=": do not call setsockopt() for
Option applied with empty value "so-reuseaddr=": do not call setsockopt() for
SO_REUSEADDR
Return 0 on success, or -1 with errno when an error occurred.
*/
@ -2335,6 +2335,7 @@ int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts)
{
union integral val;
union integral notnull;
int result;
int _errno;
val.u_int = 0;
@ -2345,7 +2346,12 @@ int xiosock_reuseaddr(int fd, int ipproto, struct opt *opts)
notnull.u_bool = true;
}
#endif /* WITH_TCP */
retropt_2integrals(opts, OPT_SO_REUSEADDR, &val, &notnull);
result = retropt_2integrals(opts, OPT_SO_REUSEADDR, &val, &notnull);
if (ipproto == IPPROTO_TCP && result < 0) {
Info("Setting SO_REUSADDR on TCP listen socket implicitly");
val.u_int = 1;
notnull.u_bool = true;
}
if (notnull.u_bool) {
if (Setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val.u_int, sizeof(int))
!= 0) {

View file

@ -3107,7 +3107,7 @@ int retropt_int(struct opt *opts, int optcode, int *result) {
/* Looks for the first option of type <optcode>. If the option is found,
this function stores its int value in *result, "consumes" the
option, and returns 0.
If the option is not found, *result is not modified, and -1 is returned. */
If the option is not found, values are not modified, and -1 is returned. */
int retropt_2integrals(struct opt *opts, int optcode,
union integral *value1, union integral *value2)
{