Merge branch 'release/0.2'

master v0.2
Geoffrey Merck 4 years ago
commit ef8e6cbe2e

@ -945,7 +945,7 @@ bool CDExtraHandler::stateChange()
return stateChange;
}
void CDExtraHandler::writeStatus(ofstream& file)
void CDExtraHandler::writeStatus(std::ofstream& file)
{
for (unsigned int i = 0U; i < m_maxReflectors; i++) {
CDExtraHandler* reflector = m_reflectors[i];

@ -909,7 +909,7 @@ bool CDPlusHandler::stateChange()
return stateChange;
}
void CDPlusHandler::writeStatus(ofstream& file)
void CDPlusHandler::writeStatus(std::ofstream& file)
{
for (unsigned int i = 0U; i < m_maxReflectors; i++) {
CDPlusHandler* reflector = m_reflectors[i];

@ -177,7 +177,7 @@ void IRCDDBApp::rptrQTH(const std::string& callsign, double latitude, double lon
CUtils::ReplaceChar(d2, ' ', '_');
CUtils::ReplaceChar(cs, ' ', '_');
d->moduleQTHURLMutex.lock();
std::lock_guard lochQTHURL(d->moduleQTHURLMutex);
d->moduleQTH[cs] = cs + std::string(" ") + pos + std::string(" ") + d1 + std::string(" ") + d2;
@ -194,7 +194,6 @@ void IRCDDBApp::rptrQTH(const std::string& callsign, double latitude, double lon
CLog::logInfo("URL: %s\n", d->moduleURL[cs].c_str());
}
d->moduleQTHURLMutex.unlock();
d->infoTimer = 5; // send info in 5 seconds
}
@ -208,10 +207,9 @@ void IRCDDBApp::rptrQRG(const std::string& callsign, double txFrequency, double
std::string f(fstr);
CUtils::ReplaceChar(f, ',', '.');
d->moduleQRGMutex.lock();
std::lock_guard lockModuleQRG(d->moduleQRGMutex);
d->moduleQRG[cs] = cs + std::string(" ") + f;
CLog::logInfo("QRG: %s\n", d->moduleQRG[cs].c_str());
d->moduleQRGMutex.unlock();
d->infoTimer = 5; // send info in 5 seconds
}
@ -229,9 +227,8 @@ void IRCDDBApp::kickWatchdog(const std::string& callsign, const std::string& s)
std::string cs = callsign;
CUtils::ReplaceChar(cs, ' ', '_');
d->moduleWDMutex.lock();
std::lock_guard lockModuleWD(d->moduleWDMutex);
d->moduleWD[cs] = cs + std::string(" ") + text;
d->moduleWDMutex.unlock();
d->wdTimer = 60;
}
}
@ -300,7 +297,7 @@ unsigned int IRCDDBApp::calculateUsn(const std::string& nick)
void IRCDDBApp::userJoin(const std::string& nick, const std::string& name, const std::string& host)
{
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
std::string lnick = nick;
CUtils::ToLower(lnick);
@ -325,7 +322,6 @@ void IRCDDBApp::userJoin(const std::string& nick, const std::string& name, const
d->replyQ.putMessage(m2);
}
}
d->userMapMutex.unlock();
}
void IRCDDBApp::userLeave(const std::string& nick)
@ -333,13 +329,12 @@ void IRCDDBApp::userLeave(const std::string& nick)
std::string lnick = nick;
CUtils::ToLower(lnick);
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
d->user.erase(lnick);
if (d->currentServer.size()) {
if (d->user.count(d->myNick) != 1) {
CLog::logInfo("IRCDDBApp::userLeave: could not find own nick\n");
d->userMapMutex.unlock();
return;
}
@ -356,14 +351,12 @@ void IRCDDBApp::userLeave(const std::string& nick)
}
}
}
d->userMapMutex.unlock();
}
void IRCDDBApp::userListReset()
{
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
d->user.clear();
d->userMapMutex.unlock();
}
void IRCDDBApp::setCurrentNick(const std::string& nick)
@ -386,7 +379,7 @@ void IRCDDBApp::setTopic(const std::string& topic)
bool IRCDDBApp::findServerUser()
{
bool found = false;
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
std::map<std::string, IRCDDBAppUserObject>::iterator it;
@ -401,7 +394,6 @@ bool IRCDDBApp::findServerUser()
}
if (found) {
d->userMapMutex.unlock();
return true;
}
@ -418,7 +410,6 @@ bool IRCDDBApp::findServerUser()
}
if (found) {
d->userMapMutex.unlock();
return true;
}
@ -430,20 +421,18 @@ bool IRCDDBApp::findServerUser()
break;
}
}
d->userMapMutex.unlock();
return found;
}
void IRCDDBApp::userChanOp(const std::string& nick, bool op)
{
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
std::string lnick = nick;
CUtils::ToLower(lnick);
if (d->user.count(lnick) == 1)
d->user[lnick].op = op;
d->userMapMutex.unlock();
}
static const int numberOfTables = 2;
@ -457,7 +446,7 @@ std::string IRCDDBApp::getIPAddress(std::string& zonerp_cs)
CUtils::ToLower(gw);
CUtils::Trim(gw);
d->userMapMutex.lock();
std::lock_guard lockUserMap(d->userMapMutex);
for (int j=1; j <= 4; j++) {
std::string ircUser = gw + std::string("-") + std::to_string(j);
@ -470,7 +459,6 @@ std::string IRCDDBApp::getIPAddress(std::string& zonerp_cs)
}
}
}
d->userMapMutex.unlock();
return ipAddr;
}
@ -531,8 +519,7 @@ bool IRCDDBApp::findRepeater(const std::string& rptrCall)
std::string s("NONE");
std::string zonerp_cs;
d->rptrMapMutex.lock();
std::lock_guard lockRptrMap(d->rptrMapMutex);
if (1 == d->rptrMap.count(arearp_cs)) {
IRCDDBAppRptrObject o = d->rptrMap[arearp_cs];
@ -741,7 +728,7 @@ void IRCDDBApp::doUpdate(std::string& msg)
return; // no valid key
if (tableID == 1) {
d->rptrMapMutex.lock();
std::lock_guard lockRptrMap(d->rptrMapMutex);
IRCDDBAppRptrObject newRptr(dt, key, value, m_maxTime);
d->rptrMap[key] = newRptr;
@ -759,9 +746,8 @@ void IRCDDBApp::doUpdate(std::string& msg)
m2->addParam(getIPAddress(value));
d->replyQ.putMessage(m2);
}
d->rptrMapMutex.unlock();
} else if (0==tableID && d->initReady) {
d->rptrMapMutex.lock();
std::lock_guard lockRptrMap(d->rptrMapMutex);
std::string userCallsign(key);
std::string arearp_cs(value);
std::string zonerp_cs;
@ -785,7 +771,6 @@ void IRCDDBApp::doUpdate(std::string& msg)
m2->addParam(ip_addr);
m2->addParam(tk + std::string(" ") + timeToken);
d->replyQ.putMessage(m2);
d->rptrMapMutex.unlock();
}
}
}
@ -980,27 +965,28 @@ void IRCDDBApp::Entry()
d->infoTimer--;
if (0 == d->infoTimer) {
d->moduleQTHURLMutex.lock();
for (auto it = d->moduleQTH.begin(); it != d->moduleQTH.end(); ++it) {
std::string value = it->second;
IRCMessage *m = new IRCMessage(d->currentServer, std::string("IRCDDB RPTRQTH: ") + value);
IRCMessageQueue *q = getSendQ();
if (q != NULL)
q->putMessage(m);
}
d->moduleQTH.clear();
for (auto it = d->moduleURL.begin(); it != d->moduleURL.end(); ++it) {
std::string value = it->second;
IRCMessage *m = new IRCMessage(d->currentServer, std::string("IRCDDB RPTRURL: ") + value);
IRCMessageQueue *q = getSendQ();
if (q != NULL)
q->putMessage(m);
{ // Scope for mutext locking
std::lock_guard lochQTHURL(d->moduleQTHURLMutex);
for (auto it = d->moduleQTH.begin(); it != d->moduleQTH.end(); ++it) {
std::string value = it->second;
IRCMessage *m = new IRCMessage(d->currentServer, std::string("IRCDDB RPTRQTH: ") + value);
IRCMessageQueue *q = getSendQ();
if (q != NULL)
q->putMessage(m);
}
d->moduleQTH.clear();
for (auto it = d->moduleURL.begin(); it != d->moduleURL.end(); ++it) {
std::string value = it->second;
IRCMessage *m = new IRCMessage(d->currentServer, std::string("IRCDDB RPTRURL: ") + value);
IRCMessageQueue *q = getSendQ();
if (q != NULL)
q->putMessage(m);
}
d->moduleURL.clear();
}
d->moduleURL.clear();
d->moduleQTHURLMutex.unlock();
d->moduleQRGMutex.lock();
std::lock_guard lockModuleQRG(d->moduleQRGMutex);
for (auto it = d->moduleQRG.begin(); it != d->moduleQRG.end(); ++it) {
std::string value = it->second;
IRCMessage* m = new IRCMessage(d->currentServer, std::string("IRCDDB RPTRQRG: ") + value);
@ -1009,7 +995,6 @@ void IRCDDBApp::Entry()
q->putMessage(m);
}
d->moduleQRG.clear();
d->moduleQRGMutex.unlock();
}
}
@ -1017,7 +1002,7 @@ void IRCDDBApp::Entry()
d->wdTimer--;
if (0 == d->wdTimer) {
d->moduleWDMutex.lock();
std::lock_guard lockModuleWD(d->moduleWDMutex);
for (auto it = d->moduleWD.begin(); it != d->moduleWD.end(); ++it) {
std::string value = it->second;
@ -1027,7 +1012,6 @@ void IRCDDBApp::Entry()
q->putMessage(m);
}
d->moduleWD.clear();
d->moduleWDMutex.unlock();
}
}
break;

@ -4,6 +4,7 @@ CIRCDDBClient - ircDDB client library in C++
Copyright (C) 2010-2011 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (C) 2011,2012 Jonathan Naylor, G4KLX
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -4,6 +4,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010-2011 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (C) 2011,2012 Jonathan Naylor, G4KLX
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -3,6 +3,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010-2011 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -3,6 +3,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -7,6 +7,9 @@ Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Completely rewritten by:
Copyright (c) 2017 by Thomas A. Early N7TAE
Bug fixed by:
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
@ -30,12 +33,11 @@ IRCMessageQueue::IRCMessageQueue()
IRCMessageQueue::~IRCMessageQueue()
{
accessMutex.lock();
std::lock_guard lockAccessQueue(accessMutex);
while (! m_queue.empty()) {
delete m_queue.front();
m_queue.pop();
}
accessMutex.unlock();
}
bool IRCMessageQueue::isEOF()
@ -50,35 +52,33 @@ void IRCMessageQueue::signalEOF()
bool IRCMessageQueue::messageAvailable()
{
accessMutex.lock();
std::lock_guard lockAccessQueue(accessMutex);
bool retv = ! m_queue.empty();
accessMutex.unlock();
return retv;
}
IRCMessage *IRCMessageQueue::peekFirst()
{
accessMutex.lock();
std::lock_guard lockAccessQueue(accessMutex);
IRCMessage *msg = m_queue.empty() ? NULL : m_queue.front();
accessMutex.unlock();
return msg;
}
IRCMessage *IRCMessageQueue::getMessage()
{
accessMutex.lock();
std::lock_guard lockAccessQueue(accessMutex);
IRCMessage *msg = m_queue.empty() ? NULL : m_queue.front();
if (msg)
m_queue.pop();
accessMutex.unlock();
return msg;
}
void IRCMessageQueue::putMessage(IRCMessage *m)
{
accessMutex.lock();
std::lock_guard lockAccessQueue(accessMutex);
m_queue.push(m);
accessMutex.unlock();
}

@ -1,12 +1,15 @@
/*
CIRCDDB - ircDDB client library in C++
Based on original code by:
Based on code by:
Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Completely rewritten by:
Copyright (c) 2017 by Thomas A. Early N7TAE
Bug fixed by:
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or

@ -3,6 +3,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010-2011 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -3,6 +3,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -3,6 +3,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -4,6 +4,7 @@ CIRCDDB - ircDDB client library in C++
Copyright (C) 2010 Michael Dirska, DL1BFF (dl1bff@mdx.de)
Copyright (C) 2012 Jonathan Naylor, G4KLX
Copyright (c) 2017 by Thomas A. Early N7TAE
Copyright (c) 2021 by Thomas Geoffrey Merck F4FXL / KC3FRA
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

@ -1,46 +0,0 @@
/*
* Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef MUTEXLOCKER_H
#define MUTEXLOCKER_H
#include <mutex>
#include <cassert>
using namespace std;
class CMutexLocker
{
public:
CMutexLocker(recursive_mutex * mutex) :
m_mutex(mutex)
{
assert(mutex != NULL);
m_mutex->lock();
}
~CMutexLocker()
{
m_mutex->unlock();
}
private:
recursive_mutex * m_mutex;
};
#endif

@ -12,7 +12,8 @@
- [4. Contributing](#4-contributing)
- [4.1. Work Flow](#41-work-flow)
- [5. Version History](#5-version-history)
- [5.1. v0.1](#51-v01)
- [5.1. v0.2](#51-v02)
- [5.2. v0.1](#52-v01)
# 1. Introduction
This is a port of G4KLX Jonathan Naylor's [ircddbGateway](https://github.com/g4klx/ircDDBGateway). It is wxWidgets free and has minimal dependencies to boost (header libs only), libconfig++ and libcurl
@ -74,5 +75,8 @@ sudo systemctl stop dstargateway.service
I Use [Git flow](https://danielkummer.github.io/git-flow-cheatsheet/) as my workflow. PR are welcome and shall be done against the develop branch and follow the Git Flow branch naming rules.
# 5. Version History
## 5.1. v0.1
## 5.1. v0.2
- [bugfix] ircDDBFreeze when repeater not found ([#1](https://github.com/F4FXL/DStarGateway/issues/1))
- Code sanitization
## 5.2. v0.1
First working version

@ -22,8 +22,7 @@
#include <cassert>
#include <cstring>
#include "MutexLocker.h"
#include <mutex>
template<class T> class CRingBuffer {
public:
@ -48,7 +47,7 @@ public:
void addData(const T data)
{
CMutexLocker locker(&m_mutex);
std::lock_guard locker(m_mutex);
m_buffer[m_iPtr++] = data;
@ -58,7 +57,7 @@ public:
T getData()
{
CMutexLocker locker(&m_mutex);
std::lock_guard locker(m_mutex);
if (m_iPtr == m_oPtr)
return NULL;
@ -73,7 +72,7 @@ public:
void clear()
{
CMutexLocker locker(&m_mutex);
std::lock_guard locker(m_mutex);
m_iPtr = 0U;
m_oPtr = 0U;
@ -83,14 +82,14 @@ public:
bool empty()
{
CMutexLocker locker(&m_mutex);
std::lock_guard locker(m_mutex);
return m_iPtr == m_oPtr;
}
T peek()
{
CMutexLocker locker(&m_mutex);
std::lock_guard locker(m_mutex);
if (m_iPtr == m_oPtr)
return NULL;
@ -103,7 +102,7 @@ private:
T* m_buffer;
volatile unsigned int m_iPtr;
volatile unsigned int m_oPtr;
recursive_mutex m_mutex;
std::recursive_mutex m_mutex;
};
#endif

@ -23,4 +23,4 @@
#include <string>
const std::string VENDOR_NAME("Geoffrey Merck F4FXL / KC3FRA");
const std::string VERSION("0.1");
const std::string VERSION("0.2");

Loading…
Cancel
Save

Powered by TurnKey Linux.