Adding socket reuse to bssl server.
This allows a server to be restarted immediately with the same port without having to wait for socket timeout on crash/failure. Change-Id: Ifcf58d46067f157dd504946f71b0b99d7fbad10c Reviewed-on: https://boringssl-review.googlesource.com/13044 Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
parent
0b8dc30932
commit
bf5bda37cf
@ -159,6 +159,7 @@ bool Accept(int *out_sock, const std::string &port) {
|
||||
addr.sin6_port = htons(atoi(port.c_str()));
|
||||
|
||||
bool ok = false;
|
||||
const char enable = 1;
|
||||
int server_sock = -1;
|
||||
|
||||
server_sock =
|
||||
@ -168,6 +169,12 @@ bool Accept(int *out_sock, const std::string &port) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (setsockopt(server_sock, SOL_SOCKET, SO_REUSEADDR, &enable,
|
||||
sizeof(enable)) < 0) {
|
||||
perror("setsockopt");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (bind(server_sock, (struct sockaddr*)&addr, sizeof(addr)) != 0) {
|
||||
perror("connect");
|
||||
goto out;
|
||||
|
Loading…
Reference in New Issue
Block a user