Get the listen backlog size from net.core.somaxconn on linux
This commit is contained in:
parent
51527e77f8
commit
041d55e584
|
@ -217,7 +217,7 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
|
|||
invalidateSocket();
|
||||
return;
|
||||
}
|
||||
if (listen(sockfd, 128) != 0) {
|
||||
if (listen(sockfd, getBacklogSize()) != 0) {
|
||||
invalidateSocket();
|
||||
return;
|
||||
}
|
||||
|
@ -955,3 +955,19 @@ private int getSocketError()
|
|||
version (Windows) return WSAGetLastError();
|
||||
else return errno;
|
||||
}
|
||||
private int getBacklogSize()
|
||||
@trusted @nogc nothrow {
|
||||
int backlog = 128;
|
||||
version(linux)
|
||||
{
|
||||
import core.stdc.stdio : fopen, fscanf;
|
||||
auto somaxconn = fopen("/proc/sys/net/core/somaxconn", "re");
|
||||
if(somaxconn)
|
||||
{
|
||||
int tmp;
|
||||
if (fscanf(somaxconn, "%d", &tmp) == 1)
|
||||
backlog = tmp;
|
||||
}
|
||||
}
|
||||
return backlog;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue