Merge pull request #71 from kubo39/somaxconn
Get the listen backlog size from net.core.somaxconn on Linux merged-on-behalf-of: Sönke Ludwig <s-ludwig@users.noreply.github.com>
This commit is contained in:
commit
ca56b31566
|
@ -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,21 @@ 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 : fclose, fopen, fscanf;
|
||||
auto somaxconn = fopen("/proc/sys/net/core/somaxconn", "re");
|
||||
if (somaxconn)
|
||||
{
|
||||
int tmp;
|
||||
if (fscanf(somaxconn, "%d", &tmp) == 1)
|
||||
backlog = tmp;
|
||||
fclose(somaxconn);
|
||||
}
|
||||
}
|
||||
return backlog;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue