mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-05-22 03:32:04 +00:00
Reduce maximum socket buffer size so select works
The maximum socket receive buffer size (SO_RCVBUF) is set from the value in /proc/sys/net/core/rmem_max. When this value is close to INT_MAX, the select() system call used by IO::Select->can_read() never returns true. This causes packets to never be read. Therefore, reduce the maximum socket receive buffer size to a value which works.
This commit is contained in:
parent
dd6731b7f4
commit
bd0ad1ba43
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user