mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-07-05 15:44:47 +02:00
esrf changes: slsReceiver: better checking of socket buffer pars. and warn on failures
* not done. The 'setsockopt(SO_RECVBUF)' system call cannot set the socket buffer
size lager than the specified in net.core.rmem_max. The requested value
was 2 GB (commit 3b0e2e6
), which is far too large for this application,
so it was restored to the acceptable 100 MB value.
* The syscall does not fail if the requested buffer size is larger than
net.core.rmem_max. Use 'setsockopt(SO_RECVBUFFORCE)' to actually force a
value larger than the system limit, which can be done if run in a
privileged context (capability CAP_NET_ADMIN set).
* The real value is read with 'getsockopt(SO_RECVBUF)'. If it
corresponds to twice the requested value (see 'man 7 socket'), it is
printed in green, otherwise it is signalled in red.
* The 'setsockopt(SO_RECVBUFFORCE)' syscall removes the need to write to
/proc/sys/net/core/rmem_max, so this was was suppressed in the
'UDPStandardImplementation' constructor.
* The test on EIGER detectors before setting the system
buffers was removed. Was there for 9m/2m eiger, but one can take care of
memory requirements using a customizable max socket buffer size(only with
permissions). to be implmented later.
* The file /proc/sys/net/core/netdev_max_backlog is first read by the
receiver to check is the current value is OK. If it is not, the receiver
directly writes the good value into the file (instead of delegating to
the system shell), printing a red error message if there is an access
error (non-privileged user).
This commit is contained in:
@ -646,28 +646,29 @@ int UDPStandardImplementation::restreamStop() {
|
||||
|
||||
|
||||
void UDPStandardImplementation::SetLocalNetworkParameters() {
|
||||
//to increase socket receiver buffer size and max length of input queue by changing kernel settings
|
||||
if (myDetectorType == EIGER)
|
||||
return;
|
||||
|
||||
char command[255];
|
||||
|
||||
//to increase Socket Receiver Buffer size
|
||||
sprintf(command,"echo $((%d)) > /proc/sys/net/core/rmem_max",RECEIVE_SOCKET_BUFFER_SIZE);
|
||||
if (system(command)) {
|
||||
FILE_LOG(logWARNING) << "No root privileges to change Socket Receiver Buffer size (net.core.rmem_max)";
|
||||
return;
|
||||
}
|
||||
FILE_LOG(logINFO) << "Socket Receiver Buffer size (/proc/sys/net/core/rmem_max) modified to " << RECEIVE_SOCKET_BUFFER_SIZE ;
|
||||
|
||||
|
||||
// to increase Max length of input packet queue
|
||||
sprintf(command,"echo %d > /proc/sys/net/core/netdev_max_backlog",MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||
if (system(command)) {
|
||||
FILE_LOG(logWARNING) << "No root privileges to change Max length of input packet queue (net.core.rmem_max)";
|
||||
return;
|
||||
int max_back_log;
|
||||
const char *proc_file_name = "/proc/sys/net/core/netdev_max_backlog";
|
||||
{
|
||||
ifstream proc_file(proc_file_name);
|
||||
proc_file >> max_back_log;
|
||||
}
|
||||
|
||||
if (max_back_log < MAX_SOCKET_INPUT_PACKET_QUEUE) {
|
||||
ofstream proc_file(proc_file_name);
|
||||
if (proc_file.good()) {
|
||||
proc_file << MAX_SOCKET_INPUT_PACKET_QUEUE << endl;
|
||||
cprintf(GREEN, "Max length of input packet queue "
|
||||
"(/proc/sys/net/core/netdev_max_backlog) modified to %d\n",
|
||||
MAX_SOCKET_INPUT_PACKET_QUEUE);
|
||||
} else {
|
||||
const char *msg = "Could not change max length of"
|
||||
"input packet queue (net.core.netdev_max_backlog): no root privileges?";
|
||||
cprintf(RED, "WARNING: %s\n", msg);
|
||||
}
|
||||
}
|
||||
FILE_LOG(logINFO) << "Max length of input packet queue (/proc/sys/net/core/netdev_max_backlog) modified to " << MAX_SOCKET_INPUT_PACKET_QUEUE ;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user