Skip to content

Commit

Permalink
apps/netutils/telnetd: Fix undefined reference to setsockopt.
Browse files Browse the repository at this point in the history
Recent change from Xiao Xiang enabled the SO_REUSEADDR socket option unconditionally.  This, of course, causes link time failures if socket options are not enabled:

apps/netutils/telnetd/telnetd_daemon.c:182: undefined reference to 'setsockopt'.

Observed during build testing with configuration rddrone-uavcan144:nsh
  • Loading branch information
gregory-nutt authored and xiaoxiang781216 committed Feb 8, 2020
1 parent f14aead commit d2522e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion netutils/telnetd/telnetd_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ static int telnetd_daemon(int argc, FAR char *argv[])
goto errout_with_daemon;
}

#ifdef CONFIG_NET_SOCKOPTS
/* Set socket to reuse address */

optval = 1;
Expand All @@ -185,6 +186,7 @@ static int telnetd_daemon(int argc, FAR char *argv[])
nerr("ERROR: setsockopt SO_REUSEADDR failure: %d\n", errno);
goto errout_with_socket;
}
#endif

/* Bind the socket to a local address */

Expand Down Expand Up @@ -261,9 +263,9 @@ static int telnetd_daemon(int argc, FAR char *argv[])
}
}

#ifdef CONFIG_NET_SOLINGER
/* Configure to "linger" until all data is sent when the socket is closed */

#ifdef CONFIG_NET_SOLINGER
ling.l_onoff = 1;
ling.l_linger = 30; /* timeout is seconds */
if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0)
Expand Down

0 comments on commit d2522e2

Please sign in to comment.