mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-07 12:18:39 +01:00
fixed validation in network_utils, added a tests to throw for port 65535 in test mode (option on for sls_use_tests), multi:parent process checks child process exit status to send sigint to others
This commit is contained in:
@@ -52,6 +52,10 @@ target_link_libraries(slsReceiverObject
|
|||||||
slsProjectWarnings #don't propagate warnigns
|
slsProjectWarnings #don't propagate warnigns
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(slsReceiverObject
|
||||||
|
PRIVATE $<$<BOOL:${SLS_USE_TESTS}>:SLS_USE_TESTS>
|
||||||
|
)
|
||||||
|
|
||||||
# HDF5
|
# HDF5
|
||||||
if (SLS_USE_HDF5)
|
if (SLS_USE_HDF5)
|
||||||
if (HDF5_FOUND)
|
if (HDF5_FOUND)
|
||||||
@@ -87,6 +91,7 @@ set_target_properties(slsReceiverStatic PROPERTIES
|
|||||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||||
PUBLIC_HEADER "${PUBLICHEADERS}"
|
PUBLIC_HEADER "${PUBLICHEADERS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND RECEIVER_LIBRARY_TARGETS slsReceiverStatic)
|
list(APPEND RECEIVER_LIBRARY_TARGETS slsReceiverStatic)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,6 @@ int main(int argc, char *argv[]) {
|
|||||||
std::cerr << "Child " << childPid << " failed\n";
|
std::cerr << "Child " << childPid << " failed\n";
|
||||||
kill(0, SIGINT); // signal other children to exit
|
kill(0, SIGINT); // signal other children to exit
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "Goodbye!\n";
|
std::cout << "Goodbye!\n";
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ Receiver::~Receiver() = default;
|
|||||||
|
|
||||||
Receiver::Receiver(uint16_t port) {
|
Receiver::Receiver(uint16_t port) {
|
||||||
validatePortNumber(port);
|
validatePortNumber(port);
|
||||||
|
#ifdef SLS_USE_TESTS
|
||||||
|
if (port == 65535) {
|
||||||
|
throw sls::RuntimeError("Throwing for testing purposes. ");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
tcpipInterface = make_unique<ClientInterface>(port);
|
tcpipInterface = make_unique<ClientInterface>(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -205,17 +205,16 @@ MacAddr InterfaceNameToMac(const std::string &inf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void validatePortNumber(uint16_t port) {
|
void validatePortNumber(uint16_t port) {
|
||||||
// random local port. might work if internal = bad practise
|
if (port < 1024 || port > std::numeric_limits<uint16_t>::max()) {
|
||||||
if (port == 0) {
|
throw RuntimeError(std::string("Invalid port number ") +
|
||||||
throw RuntimeError("Invalid port number. Must be between 1 - 65535.");
|
std::to_string(port) +
|
||||||
|
". Must be between 1024 - 65535.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void validatePortRange(uint16_t startPort, int numPorts) {
|
void validatePortRange(uint16_t startPort, int numPorts) {
|
||||||
validatePortNumber(startPort);
|
validatePortNumber(startPort);
|
||||||
if ((startPort + numPorts) > std::numeric_limits<uint16_t>::max()) {
|
validatePortNumber(startPort + numPorts - 1);
|
||||||
throw RuntimeError("Invalid port range. Must be between 1 - 65535.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace sls
|
} // namespace sls
|
||||||
|
|||||||
Reference in New Issue
Block a user