2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

Merge pull request #6375 from watson6282/net-core-rmem_max

Reduce maximum socket buffer size so select works
This commit is contained in:
cxhong 2019-07-16 15:57:59 -04:00 committed by GitHub
commit 06eb179a8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -64,6 +64,11 @@ sub dodiscover {
my $sysctl;
open($sysctl, "<", "/proc/sys/net/core/rmem_max");
my $maxrcvbuf = <$sysctl>;
# select() on a socket will never succeed if the buffer is too large (i.e. near INT_MAX)
my $cap_maxrcvbuf = 2047*1024*1024;
if ($maxrcvbuf > $cap_maxrcvbuf) {
$maxrcvbuf = $cap_maxrcvbuf;
}
my $rcvbuf = $args{'socket'}->sockopt(SO_RCVBUF);
if ($maxrcvbuf > $rcvbuf) {
$args{'socket'}->sockopt(SO_RCVBUF, $maxrcvbuf / 2);

View File

@ -209,6 +209,11 @@ sub new {
my $sysctl;
open($sysctl, "<", "/proc/sys/net/core/rmem_max");
my $maxrcvbuf = <$sysctl>;
# select() on a socket will never succeed if the buffer is too large (i.e. near INT_MAX)
my $cap_maxrcvbuf = 2047*1024*1024;
if ($maxrcvbuf > $cap_maxrcvbuf) {
$maxrcvbuf = $cap_maxrcvbuf;
}
my $rcvbuf = $socket->sockopt(SO_RCVBUF);
if ($maxrcvbuf > $rcvbuf) {
$socket->sockopt(SO_RCVBUF, $maxrcvbuf / 2);