1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Disable SO_REUSEPORT if not supported. 3.0.57

This commit is contained in:
winlin 2019-10-04 20:02:51 +08:00
parent 6f5809c80b
commit 9d90a8177f
3 changed files with 7 additions and 1 deletions

View file

@ -112,10 +112,15 @@ srs_error_t srs_fd_reuseaddr(int fd)
srs_error_t srs_fd_reuseport(int fd)
{
#if defined(SO_REUSEPORT)
int v = 1;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &v, sizeof(int)) == -1) {
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEPORT fd=%v", fd);
}
#else
#warning "SO_REUSEPORT is not supported by your OS"
srs_warn("SO_REUSEPORT is not supported util Linux kernel 3.9");
#endif
return srs_success;
}