Merge branch 'develop' into feature/AddTimeServer_#20

pull/32/head
Geoffrey Merck 5 years ago
commit 2eeb3336a5

@ -18,10 +18,12 @@
#include <cassert> #include <cassert>
#include "Thread.h" #include "Thread.h"
#include "Log.h"
using namespace std; using namespace std;
CThread::CThread() CThread::CThread(const std::string& name) :
m_name(name)
{ {
} }
@ -53,5 +55,7 @@ void CThread::Wait()
void CThread::EntryRunner(CThread * thread) void CThread::EntryRunner(CThread * thread)
{ {
assert(thread != nullptr);
thread->Entry(); thread->Entry();
CLog::logTrace("Exiting %s thread", thread->m_name.c_str());
} }

@ -23,10 +23,11 @@
#define Thread_H #define Thread_H
#include <thread> #include <thread>
#include <string>
class CThread { class CThread {
public: public:
CThread(); CThread(const std::string& name);
virtual ~CThread(); virtual ~CThread();
void Create(); void Create();
void Run(); void Run();
@ -39,6 +40,7 @@ protected:
private: private:
static void EntryRunner(CThread * thread); static void EntryRunner(CThread * thread);
std::string m_name;
std::thread m_thread; std::thread m_thread;
}; };

@ -37,7 +37,7 @@ const unsigned int APRS_READ_TIMEOUT = 1U;
const unsigned int APRS_KEEP_ALIVE_TIMEOUT = 60U; const unsigned int APRS_KEEP_ALIVE_TIMEOUT = 60U;
CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port) : CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port) :
CThread(), CThread("APRS"),
m_username(callsign), m_username(callsign),
m_password(password), m_password(password),
m_ssid(callsign), m_ssid(callsign),
@ -65,7 +65,7 @@ m_clientName(FULL_PRODUCT_NAME)
} }
CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter) : CAPRSHandlerThread::CAPRSHandlerThread(const std::string& callsign, const std::string& password, const std::string& address, const std::string& hostname, unsigned int port, const std::string& filter) :
CThread(), CThread("APRS"),
m_username(callsign), m_username(callsign),
m_password(password), m_password(password),
m_ssid(callsign), m_ssid(callsign),

@ -34,6 +34,7 @@ const unsigned int OPENDSTAR_PORT = 20001U;
const unsigned int TCP_TIMEOUT = 10U; const unsigned int TCP_TIMEOUT = 10U;
CDPlusAuthenticator::CDPlusAuthenticator(const std::string& loginCallsign, const std::string& gatewayCallsign, const std::string& address, CCacheManager* cache) : CDPlusAuthenticator::CDPlusAuthenticator(const std::string& loginCallsign, const std::string& gatewayCallsign, const std::string& address, CCacheManager* cache) :
CThread("DPlus"),
m_loginCallsign(loginCallsign), m_loginCallsign(loginCallsign),
m_gatewayCallsign(gatewayCallsign), m_gatewayCallsign(gatewayCallsign),
m_address(address), m_address(address),
@ -106,7 +107,7 @@ void* CDPlusAuthenticator::Entry()
void CDPlusAuthenticator::stop() void CDPlusAuthenticator::stop()
{ {
m_killed = true; m_killed = true;
CLog::logInfo("Stopping DPpus Authenticator");
Wait(); Wait();
} }

@ -32,6 +32,7 @@ const unsigned int LOOP_DELAY = 5UL;
const unsigned int LOOP_TICKS = 200U; const unsigned int LOOP_TICKS = 200U;
CIcomRepeaterProtocolHandler::CIcomRepeaterProtocolHandler(const std::string& address, unsigned int port, const std::string& icomAddress, unsigned int icomPort) : CIcomRepeaterProtocolHandler::CIcomRepeaterProtocolHandler(const std::string& address, unsigned int port, const std::string& icomAddress, unsigned int icomPort) :
CThread("Icom Protocol Handler"),
m_socket(address, port), m_socket(address, port),
m_icomAddress(), m_icomAddress(),
m_icomPort(icomPort), m_icomPort(icomPort),
@ -527,7 +528,7 @@ CAMBEData* CIcomRepeaterProtocolHandler::readBusyAMBE()
void CIcomRepeaterProtocolHandler::close() void CIcomRepeaterProtocolHandler::close()
{ {
m_killed = true; m_killed = true;
CLog::logInfo("Stopping Icom Repeater protocol handler thread");
Wait(); Wait();
} }

@ -46,6 +46,8 @@
#include "APRSGPSDIdFrameProvider.h" #include "APRSGPSDIdFrameProvider.h"
#include "APRSFixedIdFrameProvider.h" #include "APRSFixedIdFrameProvider.h"
CDStarGatewayApp * CDStarGatewayApp::g_app = nullptr;
#ifdef UNIT_TESTS #ifdef UNIT_TESTS
int fakemain(int argc, char *argv[]) int fakemain(int argc, char *argv[])
#else #else
@ -58,7 +60,8 @@ int main(int argc, char *argv[])
signal(SIGILL, CDStarGatewayApp::sigHandlerFatal); signal(SIGILL, CDStarGatewayApp::sigHandlerFatal);
signal(SIGFPE, CDStarGatewayApp::sigHandlerFatal); signal(SIGFPE, CDStarGatewayApp::sigHandlerFatal);
signal(SIGABRT, CDStarGatewayApp::sigHandlerFatal); signal(SIGABRT, CDStarGatewayApp::sigHandlerFatal);
// signal(SIGTERM, CDStarGatewayApp::sigHandler); signal(SIGTERM, CDStarGatewayApp::sigHandler);
signal(SIGINT, CDStarGatewayApp::sigHandler);
setbuf(stdout, NULL); setbuf(stdout, NULL);
if (2 != argc) { if (2 != argc) {
@ -89,6 +92,7 @@ int main(int argc, char *argv[])
CDStarGatewayApp::CDStarGatewayApp(const std::string &configFile) : m_configFile(configFile), m_thread(NULL) CDStarGatewayApp::CDStarGatewayApp(const std::string &configFile) : m_configFile(configFile), m_thread(NULL)
{ {
g_app = this;
} }
CDStarGatewayApp::~CDStarGatewayApp() CDStarGatewayApp::~CDStarGatewayApp()
@ -276,6 +280,15 @@ bool CDStarGatewayApp::createThread()
return true; return true;
} }
void CDStarGatewayApp::sigHandler(int sig)
{
CLog::logInfo("Caught signal : %s, shutting down gateway", strsignal(sig));
if(g_app != nullptr && g_app->m_thread != nullptr) {
g_app->m_thread->kill();
}
}
void CDStarGatewayApp::sigHandlerFatal(int sig) void CDStarGatewayApp::sigHandlerFatal(int sig)
{ {
CLog::logFatal("Caught signal : %s", strsignal(sig)); CLog::logFatal("Caught signal : %s", strsignal(sig));
@ -289,7 +302,6 @@ void CDStarGatewayApp::sigHandlerFatal(int sig)
void CDStarGatewayApp::terminateHandler() void CDStarGatewayApp::terminateHandler()
{ {
#ifdef DEBUG_DSTARGW #ifdef DEBUG_DSTARGW
std::stringstream stackTrace; std::stringstream stackTrace;
stackTrace << boost::stacktrace::stacktrace(); stackTrace << boost::stacktrace::stacktrace();

@ -21,7 +21,6 @@
#include "DStarGatewayThread.h" #include "DStarGatewayThread.h"
void __sigHandler(int sig);
class CDStarGatewayApp class CDStarGatewayApp
{ {
@ -29,6 +28,7 @@ private:
std::string m_configFile; std::string m_configFile;
CDStarGatewayThread *m_thread; CDStarGatewayThread *m_thread;
bool createThread(); bool createThread();
static CDStarGatewayApp * g_app;
public: public:
CDStarGatewayApp(const std::string &configFile); CDStarGatewayApp(const std::string &configFile);
@ -38,5 +38,6 @@ public:
void run(); void run();
static void sigHandlerFatal(int sig); static void sigHandlerFatal(int sig);
static void sigHandler(int sig);
static void terminateHandler(); static void terminateHandler();
}; };

@ -60,7 +60,7 @@ const std::string LOOPBACK_ADDRESS("127.0.0.1");
const unsigned int REMOTE_DUMMY_PORT = 65016U; const unsigned int REMOTE_DUMMY_PORT = 65016U;
CDStarGatewayThread::CDStarGatewayThread(const std::string& logDir, const std::string& dataDir, const std::string& name) : CDStarGatewayThread::CDStarGatewayThread(const std::string& logDir, const std::string& dataDir, const std::string& name) :
CThread(), CThread("Gateway"),
m_logDir(logDir), m_logDir(logDir),
m_dataDir(dataDir), m_dataDir(dataDir),
m_name(name), m_name(name),
@ -481,11 +481,18 @@ void* CDStarGatewayThread::Entry()
delete m_remote; delete m_remote;
} }
if(m_aprsWriter != nullptr) {
m_aprsWriter->close();
delete m_aprsWriter;
}
if (headerLogger != NULL) { if (headerLogger != NULL) {
headerLogger->close(); headerLogger->close();
delete headerLogger; delete headerLogger;
} }
CDPlusHandler::finalise();
return NULL; return NULL;
} }

@ -34,7 +34,7 @@ This is a port of G4KLX Jonathan Naylor's [ircddbGateway](https://github.com/g4k
# 2. Current State # 2. Current State
## 2.1. Code sanity ## 2.1. Code sanity
The current code is working, yet ugly IMHO as it is a mix of C and C++ of various ages. I realised that G4KLx started programming this over a decade ago, when C++11 was not yet a thing ! The current code is working, yet it is a mix of C and C++ of various ages and there is plenty of room for rework. I realised that G4KLx started programming this over a decade ago, when C++11 was not yet a thing !
The code has also been amended to no longer rely on compiler defines for paths like log or data. These can be set in configuration file. The code has also been amended to no longer rely on compiler defines for paths like log or data. These can be set in configuration file.
@ -45,7 +45,7 @@ Quite a few classes are more or less copy/paste from each other some sanitizatio
- Geoffrey Merck F4FXL / KC3FRA [That's me !](https://github.com/F4FXL/) - Geoffrey Merck F4FXL / KC3FRA [That's me !](https://github.com/F4FXL/)
## 2.3. Thanks ## 2.3. Thanks
- Cyrille F1MHV / DF1CHB for the testing - Cyrille F1MHV / DF1CHB for the testing
- Jonathan Naylor G4KLX for all the work ahead - Jonathan Naylor G4KLX for all the work ahead and the rock solid code base
## 2.4. Features ## 2.4. Features
All the features found in ircddbGateway are supposed to be working. Except the ones listed below All the features found in ircddbGateway are supposed to be working. Except the ones listed below
@ -135,6 +135,7 @@ the testing framwework used is Google Test.
# 5. Version History # 5. Version History
## 5.1. Version 0.6 ## 5.1. Version 0.6
- [Improvement] Gracefully exit on SIGINT and SIGTERM ([#21](https://github.com/F4FXL/DStarGateway/issues/21))
- [Improvement] Add text transmit utility dgwtexttransmit ([#18](https://github.com/F4FXL/DStarGateway/issues/18)) - [Improvement] Add text transmit utility dgwtexttransmit ([#18](https://github.com/F4FXL/DStarGateway/issues/18))
- [Improvement] Add voice transmit utility dgwvoicetransmit ([#18](https://github.com/F4FXL/DStarGateway/issues/18)) - [Improvement] Add voice transmit utility dgwvoicetransmit ([#18](https://github.com/F4FXL/DStarGateway/issues/18))
## 5.2. Version 0.5 ## 5.2. Version 0.5

Loading…
Cancel
Save

Powered by TurnKey Linux.