Fix rx arping socket bind (#646)

* first tries with a process intead of thread for rx_arping

* Moving delete pointer of udp socket to stopReciever,so rx_arping can only be set when udp socket is closed

* refactoring and formatting

* unused variable processId

* ignore sigchild to prevent zombie from child processes being killed
This commit is contained in:
Dhanya Thattil
2023-02-03 17:18:09 +01:00
committed by GitHub
parent e172df79f3
commit ebb6f53b21
9 changed files with 75 additions and 52 deletions

View File

@ -2,15 +2,15 @@
// Copyright (C) 2021 Contributors to the SLS Detector Package
#pragma once
/**
*@short creates/destroys an ARPing thread to arping the interfaces slsReceiver
is listening to.
*@short creates/destroys an ARPing child process to arping the interfaces
slsReceiver is listening to.
*/
#include "receiver_defs.h"
#include "sls/logger.h"
#include <atomic>
#include <thread>
#include <unistd.h>
namespace sls {
@ -22,21 +22,21 @@ class Arping {
void SetInterfacesAndIps(const int index, const std::string &interface,
const std::string &ip);
pid_t GetThreadId() const;
pid_t GetProcessId() const;
bool IsRunning() const;
void StartThread();
void StopThread();
void StartProcess();
void StopProcess();
private:
void TestCommands();
std::string ExecuteCommands();
void ThreadExecution();
void ProcessExecution();
std::vector<std::string> commands =
std::vector<std::string>(MAX_NUMBER_OF_LISTENING_THREADS);
std::atomic<bool> runningFlag{false};
std::thread t;
std::atomic<pid_t> threadId{0};
std::atomic<pid_t> childPid{0};
static const int timeIntervalSeconds = 60;
};
} // namespace sls