scoutfs: use SO_REUSEADDR for server socket

The server's listening address is fixed by the raft config in the super
block.  If it shuts down and rapidly starts back up it needs to bind to
the currently lingering address.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2019-02-24 12:04:33 -08:00
committed by Zach Brown
parent 0bc0ff9300
commit fa3e0a31c7

View File

@@ -1360,6 +1360,7 @@ int scoutfs_net_bind(struct super_block *sb,
{
struct socket *sock = NULL;
int addrlen;
int optval;
int ret;
/* caller state machine shouldn't let this happen */
@@ -1370,6 +1371,12 @@ int scoutfs_net_bind(struct super_block *sb,
if (ret)
goto out;
optval = 1;
ret = kernel_setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
(char *)&optval, sizeof(optval));
if (ret)
goto out;
addrlen = sizeof(struct sockaddr_in);
ret = kernel_bind(sock, (struct sockaddr *)sin, addrlen);
if (ret)