Merge branch 'develop' into feature/AddTimeServer_#20

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

@ -18,10 +18,12 @@
#include <cassert>
#include "Thread.h"
#include "Log.h"
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)
{
assert(thread != nullptr);
thread->Entry();
CLog::logTrace("Exiting %s thread", thread->m_name.c_str());
}

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

@ -37,7 +37,7 @@ const unsigned int APRS_READ_TIMEOUT = 1U;
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) :
CThread(),
CThread("APRS"),
m_username(callsign),
m_password(password),
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) :
CThread(),
CThread("APRS"),
m_username(callsign),
m_password(password),
m_ssid(callsign),

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

@ -32,6 +32,7 @@ const unsigned int LOOP_DELAY = 5UL;
const unsigned int LOOP_TICKS = 200U;
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_icomAddress(),
m_icomPort(icomPort),
@ -527,7 +528,7 @@ CAMBEData* CIcomRepeaterProtocolHandler::readBusyAMBE()
void CIcomRepeaterProtocolHandler::close()
{
m_killed = true;
CLog::logInfo("Stopping Icom Repeater protocol handler thread");
Wait();
}

@ -46,6 +46,8 @@
#include "APRSGPSDIdFrameProvider.h"
#include "APRSFixedIdFrameProvider.h"
CDStarGatewayApp * CDStarGatewayApp::g_app = nullptr;
#ifdef UNIT_TESTS
int fakemain(int argc, char *argv[])
#else
@ -58,7 +60,8 @@ int main(int argc, char *argv[])
signal(SIGILL, CDStarGatewayApp::sigHandlerFatal);
signal(SIGFPE, CDStarGatewayApp::sigHandlerFatal);
signal(SIGABRT, CDStarGatewayApp::sigHandlerFatal);
// signal(SIGTERM, CDStarGatewayApp::sigHandler);
signal(SIGTERM, CDStarGatewayApp::sigHandler);
signal(SIGINT, CDStarGatewayApp::sigHandler);
setbuf(stdout, NULL);
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)
{
g_app = this;
}
CDStarGatewayApp::~CDStarGatewayApp()
@ -276,6 +280,15 @@ bool CDStarGatewayApp::createThread()
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)
{
CLog::logFatal("Caught signal : %s", strsignal(sig));
@ -289,7 +302,6 @@ void CDStarGatewayApp::sigHandlerFatal(int sig)
void CDStarGatewayApp::terminateHandler()
{
#ifdef DEBUG_DSTARGW
std::stringstream stackTrace;
stackTrace << boost::stacktrace::stacktrace();

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

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

@ -34,7 +34,7 @@ This is a port of G4KLX Jonathan Naylor's [ircddbGateway](https://github.com/g4k
# 2. Current State
## 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.
@ -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/)
## 2.3. Thanks
- 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
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.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 voice transmit utility dgwvoicetransmit ([#18](https://github.com/F4FXL/DStarGateway/issues/18))
## 5.2. Version 0.5

Loading…
Cancel
Save

Powered by TurnKey Linux.