move cache inside CIRCDDB

pull/14/head
Tom Early 6 years ago
parent 18c511c8f6
commit 98adbcb0e6

@ -54,7 +54,7 @@
#define CFG_DIR "/usr/local/etc" #define CFG_DIR "/usr/local/etc"
#endif #endif
const std::string GW_VERSION("QnetGateway-200320"); const std::string GW_VERSION("QnetGateway-326");
static std::atomic<bool> keep_running(true); static std::atomic<bool> keep_running(true);
@ -452,7 +452,7 @@ void CQnetGateway::GetIRCDataThread(const int i)
ii[i]->receivePing(rptr); ii[i]->receivePing(rptr);
if (! rptr.empty()) { if (! rptr.empty()) {
ReplaceChar(rptr, '_', ' '); ReplaceChar(rptr, '_', ' ');
cache[i].findRptrData(rptr, gate, addr); ii[i]->cache.findRptrData(rptr, gate, addr);
if (addr.empty()) if (addr.empty())
break; break;
CSockAddress to; CSockAddress to;
@ -481,7 +481,7 @@ int CQnetGateway::get_yrcall_rptr_from_cache(const int i, const std::string &cal
{ {
switch (RoU) { switch (RoU) {
case 'U': case 'U':
cache[i].findUserData(call, rptr, gate, addr); ii[i]->cache.findUserData(call, rptr, gate, addr);
if (rptr.empty()) { if (rptr.empty()) {
printf("Could not find last heard repeater for user '%s'\n", call.c_str()); printf("Could not find last heard repeater for user '%s'\n", call.c_str());
return 1; return 1;
@ -489,7 +489,7 @@ int CQnetGateway::get_yrcall_rptr_from_cache(const int i, const std::string &cal
break; break;
case 'R': case 'R':
rptr.assign(call); rptr.assign(call);
cache[i].findRptrData(call, gate, addr); ii[i]->cache.findRptrData(call, gate, addr);
break; break;
default: default:
fprintf(stderr, "ERROR: Invalid Rou of '%c'\n", RoU); fprintf(stderr, "ERROR: Invalid Rou of '%c'\n", RoU);
@ -2340,7 +2340,7 @@ bool CQnetGateway::Init(char *cfgfile)
for (int j=0; j<2; j++) { for (int j=0; j<2; j++) {
if (ircddb[j].ip.empty()) if (ircddb[j].ip.empty())
continue; continue;
ii[j] = new CIRCDDB(ircddb[j].ip, ircddb[j].port, owner, IRCDDB_PASSWORD[j], GW_VERSION.c_str(), &cache[j]); ii[j] = new CIRCDDB(ircddb[j].ip, ircddb[j].port, owner, IRCDDB_PASSWORD[j], GW_VERSION.c_str());
bool ok = ii[j]->open(); bool ok = ii[j]->open();
if (!ok) { if (!ok) {
printf("%s open failed\n", ircddb[j].ip.c_str()); printf("%s open failed\n", ircddb[j].ip.c_str());

@ -25,7 +25,6 @@
#include "aprs.h" #include "aprs.h"
#include "SockAddress.h" #include "SockAddress.h"
#include "QnetDB.h" #include "QnetDB.h"
#include "CacheManager.h"
#include "DStarDecode.h" #include "DStarDecode.h"
#define MAXHOSTNAMELEN 64 #define MAXHOSTNAMELEN 64
@ -158,9 +157,6 @@ private:
// for bit error rate calcs // for bit error rate calcs
CDStarDecode decode; CDStarDecode decode;
// CACHE used to cache users, repeaters, gateways and addresses
CCacheManager cache[2];
// dtmf stuff // dtmf stuff
int dtmf_buf_count[3]; int dtmf_buf_count[3];
char dtmf_buf[3][MAX_DTMF_BUF + 1]; char dtmf_buf[3][MAX_DTMF_BUF + 1];

@ -4,14 +4,12 @@
#include "IRCDDBApp.h" #include "IRCDDBApp.h"
#include "IRCutils.h" #include "IRCutils.h"
CIRCDDB::CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo, CCacheManager *cache) CIRCDDB::CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo)
{ {
this->cache = cache;
const std::string update_channel("#dstar"); const std::string update_channel("#dstar");
app = new IRCDDBApp(update_channel, cache); app = new IRCDDBApp(update_channel, &cache);
client = new IRCClient(app, update_channel, hostName, port, callsign, password, versionInfo); client = new IRCClient(app, update_channel, hostName, port, callsign, password, versionInfo);
} }

@ -21,7 +21,7 @@ class IRCClient;
class CIRCDDB class CIRCDDB
{ {
public: public:
CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo, CCacheManager *cache); CIRCDDB(const std::string &hostName, unsigned int port, const std::string &callsign, const std::string &password, const std::string &versionInfo);
~CIRCDDB(); ~CIRCDDB();
// returns the socket family type // returns the socket family type
@ -106,8 +106,9 @@ public:
void close(); // Implictely kills any threads in the IRC code void close(); // Implictely kills any threads in the IRC code
CCacheManager cache;
private: private:
IRCDDBApp *app; IRCDDBApp *app;
IRCClient *client; IRCClient *client;
CCacheManager *cache;
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.