mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
rxr: udp socket size max of INT_MAX/2 (#191)
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <limits.h>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
@ -1138,15 +1139,22 @@ int ClientInterface::get_additional_json_header(Interface &socket) {
|
||||
}
|
||||
|
||||
int ClientInterface::set_udp_socket_buffer_size(Interface &socket) {
|
||||
auto index = socket.Receive<int64_t>();
|
||||
if (index >= 0) {
|
||||
verifyIdle(socket);
|
||||
LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << index;
|
||||
impl()->setUDPSocketBufferSize(index);
|
||||
auto size = socket.Receive<int>();
|
||||
if (size == 0) {
|
||||
throw RuntimeError("Receiver socket buffer size must be > 0.");
|
||||
}
|
||||
int64_t retval = impl()->getUDPSocketBufferSize();
|
||||
if (index != 0)
|
||||
validate(index, retval,
|
||||
if (size > 0) {
|
||||
verifyIdle(socket);
|
||||
if (size > INT_MAX / 2) {
|
||||
throw RuntimeError(
|
||||
"Receiver socket buffer size exceeded max (INT_MAX/2)");
|
||||
}
|
||||
LOG(logDEBUG1) << "Setting UDP Socket Buffer size: " << size;
|
||||
impl()->setUDPSocketBufferSize(size);
|
||||
}
|
||||
int retval = impl()->getUDPSocketBufferSize();
|
||||
if (size != 0)
|
||||
validate(size, retval,
|
||||
"set udp socket buffer size (No CAP_NET_ADMIN privileges?)",
|
||||
DEC);
|
||||
LOG(logDEBUG1) << "UDP Socket Buffer Size:" << retval;
|
||||
|
@ -946,12 +946,14 @@ void Implementation::setUDPPortNumber2(const uint32_t i) {
|
||||
LOG(logINFO) << "UDP Port Number[1]: " << udpPortNum[1];
|
||||
}
|
||||
|
||||
int64_t Implementation::getUDPSocketBufferSize() const {
|
||||
int Implementation::getUDPSocketBufferSize() const {
|
||||
return udpSocketBufferSize;
|
||||
}
|
||||
|
||||
void Implementation::setUDPSocketBufferSize(const int64_t s) {
|
||||
int64_t size = (s == 0) ? udpSocketBufferSize : s;
|
||||
void Implementation::setUDPSocketBufferSize(const int s) {
|
||||
// custom setup is not 0 (must complain if set up didnt work)
|
||||
// testing default setup at startup, argument is 0 to use default values
|
||||
int size = (s == 0) ? udpSocketBufferSize : s;
|
||||
size_t listSize = listener.size();
|
||||
if (myDetectorType == JUNGFRAU && (int)listSize != numUDPInterfaces) {
|
||||
throw sls::RuntimeError(
|
||||
@ -959,12 +961,17 @@ void Implementation::setUDPSocketBufferSize(const int64_t s) {
|
||||
" do not match listener size " + std::to_string(listSize));
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < listSize; ++i) {
|
||||
listener[i]->CreateDummySocketForUDPSocketBufferSize(size);
|
||||
for (auto &l : listener) {
|
||||
l->CreateDummySocketForUDPSocketBufferSize(size);
|
||||
}
|
||||
// custom and didnt set, throw error
|
||||
if (s != 0 && udpSocketBufferSize != s) {
|
||||
throw sls::RuntimeError("Could not set udp socket buffer size. (No "
|
||||
"CAP_NET_ADMIN privileges?)");
|
||||
}
|
||||
}
|
||||
|
||||
int64_t Implementation::getActualUDPSocketBufferSize() const {
|
||||
int Implementation::getActualUDPSocketBufferSize() const {
|
||||
return actualUDPSocketBufferSize;
|
||||
}
|
||||
|
||||
|
@ -108,9 +108,9 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
uint32_t getUDPPortNumber2() const;
|
||||
/* [Eiger][Jungfrau] */
|
||||
void setUDPPortNumber2(const uint32_t i);
|
||||
int64_t getUDPSocketBufferSize() const;
|
||||
void setUDPSocketBufferSize(const int64_t s);
|
||||
int64_t getActualUDPSocketBufferSize() const;
|
||||
int getUDPSocketBufferSize() const;
|
||||
void setUDPSocketBufferSize(const int s);
|
||||
int getActualUDPSocketBufferSize() const;
|
||||
|
||||
/**************************************************
|
||||
* *
|
||||
@ -302,8 +302,8 @@ class Implementation : private virtual slsDetectorDefs {
|
||||
std::array<std::string, MAX_NUMBER_OF_LISTENING_THREADS> eth;
|
||||
std::array<uint32_t, MAX_NUMBER_OF_LISTENING_THREADS> udpPortNum{
|
||||
{DEFAULT_UDP_PORTNO, DEFAULT_UDP_PORTNO + 1}};
|
||||
int64_t udpSocketBufferSize{0};
|
||||
int64_t actualUDPSocketBufferSize{0};
|
||||
int udpSocketBufferSize{0};
|
||||
int actualUDPSocketBufferSize{0};
|
||||
|
||||
// zmq parameters
|
||||
bool dataStreamEnable{false};
|
||||
|
@ -21,14 +21,12 @@ const std::string Listener::TypeName = "Listener";
|
||||
|
||||
Listener::Listener(int ind, detectorType dtype, Fifo *f,
|
||||
std::atomic<runStatus> *s, uint32_t *portno, std::string *e,
|
||||
uint64_t *nf, int64_t *us, int64_t *as,
|
||||
uint32_t *fpf, frameDiscardPolicy *fdp, bool *act,
|
||||
bool *depaden, bool *sm)
|
||||
uint64_t *nf, int *us, int *as, uint32_t *fpf,
|
||||
frameDiscardPolicy *fdp, bool *act, bool *depaden, bool *sm)
|
||||
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s),
|
||||
udpPortNumber(portno), eth(e), numImages(nf),
|
||||
udpSocketBufferSize(us), actualUDPSocketBufferSize(as),
|
||||
framesPerFile(fpf), frameDiscardMode(fdp), activated(act),
|
||||
deactivatedPaddingEnable(depaden), silentMode(sm) {
|
||||
udpPortNumber(portno), eth(e), numImages(nf), udpSocketBufferSize(us),
|
||||
actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp),
|
||||
activated(act), deactivatedPaddingEnable(depaden), silentMode(sm) {
|
||||
LOG(logDEBUG) << "Listener " << ind << " created";
|
||||
}
|
||||
|
||||
@ -142,7 +140,7 @@ void Listener::ShutDownUDPSocket() {
|
||||
}
|
||||
}
|
||||
|
||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
|
||||
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port "
|
||||
<< *udpPortNumber;
|
||||
|
||||
@ -151,7 +149,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int64_t s) {
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t temp = *udpSocketBufferSize;
|
||||
int temp = *udpSocketBufferSize;
|
||||
*udpSocketBufferSize = s;
|
||||
|
||||
// if eth is mistaken with ip address
|
||||
|
@ -41,9 +41,9 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* @param sm pointer to silent mode
|
||||
*/
|
||||
Listener(int ind, detectorType dtype, Fifo *f, std::atomic<runStatus> *s,
|
||||
uint32_t *portno, std::string *e, uint64_t *nf,
|
||||
int64_t *us, int64_t *as, uint32_t *fpf, frameDiscardPolicy *fdp,
|
||||
bool *act, bool *depaden, bool *sm);
|
||||
uint32_t *portno, std::string *e, uint64_t *nf, int *us, int *as,
|
||||
uint32_t *fpf, frameDiscardPolicy *fdp, bool *act, bool *depaden,
|
||||
bool *sm);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
@ -98,7 +98,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
* to set & get actual buffer size
|
||||
* @param s UDP socket buffer size to be set
|
||||
*/
|
||||
void CreateDummySocketForUDPSocketBufferSize(int64_t s);
|
||||
void CreateDummySocketForUDPSocketBufferSize(int s);
|
||||
|
||||
/**
|
||||
* Set hard coded (calculated but not from detector) row and column
|
||||
@ -173,10 +173,10 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
|
||||
uint64_t *numImages;
|
||||
|
||||
/** UDP Socket Buffer Size */
|
||||
int64_t *udpSocketBufferSize;
|
||||
int *udpSocketBufferSize;
|
||||
|
||||
/** actual UDP Socket Buffer Size (double due to kernel bookkeeping) */
|
||||
int64_t *actualUDPSocketBufferSize;
|
||||
int *actualUDPSocketBufferSize;
|
||||
|
||||
/** frames per file */
|
||||
uint32_t *framesPerFile;
|
||||
|
Reference in New Issue
Block a user