Compare commits

...

10 Commits

4 changed files with 68 additions and 1 deletions

View File

@ -140,6 +140,19 @@ the risk of some client overwhelming the reflector with requests causing
disturbances in the reflector operation.
Example: HTTP_SRV_PORT=8080
.TP
.B CTRL_PTY
Define a path for a pseudo tty device to change parameters of the svxreflector
on runtime. The idea behind is that e.g. SQL_TIMEOUT can be changed from 300 to
1200 seconds if a broadcast (qst) is sent without restarting the svxreflector.
The device may be defined as CTRL_PTY=/tmp/ctrl_pty
To change the value you may send a command to the device like this:
echo "SQL_TIMEOUT_BLOCKTIME" > /tmp/ctrl_pty
You can change this parameters where xxx stands for the time in seconds.
SQL_TIMEOUT_BLOCKTIME=xxx
or
SQL_TIMEOUT=xxx
.
.SS USERS and PASSWORDS sections
.

View File

@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <AsyncTcpServer.h>
#include <AsyncUdpSocket.h>
#include <AsyncApplication.h>
#include <AsyncPty.h>
#include <common.h>
@ -123,7 +124,7 @@ namespace {
Reflector::Reflector(void)
: m_srv(0), m_udp_sock(0), m_tg_for_v1_clients(1), m_random_qsy_lo(0),
m_random_qsy_hi(0), m_random_qsy_tg(0), m_http_server(0)
m_random_qsy_hi(0), m_random_qsy_tg(0), m_http_server(0), ctrl_pty(0)
{
TGHandler::instance()->talkerUpdated.connect(
mem_fun(*this, &Reflector::onTalkerUpdated));
@ -143,6 +144,8 @@ Reflector::~Reflector(void)
m_client_con_map.clear();
ReflectorClient::cleanup();
delete TGHandler::instance();
delete ctrl_pty;
ctrl_pty = 0;
} /* Reflector::~Reflector */
@ -226,6 +229,23 @@ bool Reflector::initialize(Async::Config &cfg)
sigc::mem_fun(*this, &Reflector::httpClientDisconnected));
}
// the pty path: change params by pty commands
string pty_path;
m_cfg->getValue("GLOBAL", "CTRL_PTY", pty_path);
if (!pty_path.empty())
{
ctrl_pty = new Pty(pty_path);
if (!ctrl_pty->open())
{
cerr << "*** ERROR: Could not open ctrl PTY "
<< pty_path << " as specified in configuration variable "
<< "GLOBAL/" << "CTRL_PTY" << endl;
return false;
}
ctrl_pty->dataReceived.connect(
mem_fun(*this, &Reflector::ctrlPtyReceived));
}
return true;
} /* Reflector::initialize */
@ -783,6 +803,36 @@ uint32_t Reflector::nextRandomQsyTg(void)
} /* Reflector::nextRandomQsyTg */
void Reflector::ctrlPtyReceived(const void *buf, size_t count)
{
const char *buffer = reinterpret_cast<const char*>(buf);
std::string injmessage = "";
int t;
for (size_t i=0; i<count-1; i++)
{
injmessage += *buffer++;
}
size_t f = injmessage.find("SQL_TIMEOUT_BLOCKTIME=");
if (f != std::string::npos)
{
t = atoi(injmessage.erase(f,22+f).c_str());
TGHandler::instance()->setSqlTimeoutBlocktime(t);
cout << "+++ new value for SQL_TIMEOUT_BLOCKTIME="
<< t << endl;
return;
}
f = injmessage.find("SQL_TIMEOUT=");
if (f != std::string::npos)
{
t = atoi(injmessage.erase(f,12+f).c_str());
TGHandler::instance()->setSqlTimeout(t);
cout << "+++ new value for SQL_TIMEOUT=" << t << endl;
}
} /* Reflector::ctrlPtyReceived */
/*
* This file has not been truncated
*/

View File

@ -72,6 +72,7 @@ namespace Async
{
class UdpSocket;
class Config;
class Pty;
};
class ReflectorMsg;
@ -195,6 +196,7 @@ class Reflector : public sigc::trackable
uint32_t m_random_qsy_hi;
uint32_t m_random_qsy_tg;
Async::TcpServer<Async::HttpServerConnection>* m_http_server;
Async::Pty *ctrl_pty;
Reflector(const Reflector&);
Reflector& operator=(const Reflector&);
@ -212,6 +214,7 @@ class Reflector : public sigc::trackable
Async::HttpServerConnection::DisconnectReason reason);
void onRequestAutoQsy(uint32_t from_tg);
uint32_t nextRandomQsyTg(void);
void ctrlPtyReceived(const void *buf, size_t count);
}; /* class Reflector */

View File

@ -14,6 +14,7 @@ LISTEN_PORT=5300
TG_FOR_V1_CLIENTS=999
#RANDOM_QSY_RANGE=12399:100
#HTTP_SRV_PORT=8080
CTRL_PTY=/tmp/ctrl_pty
[USERS]
#SM0ABC-1=MyNodes