}
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "REMOTE_SCRIPT::Reload()\n");
authorizedUsers.end(),
UpdateRouter(*this));
+logger("%s reloaded successfully.", rsSettings.GetMapFileName().c_str());
+printfd(__FILE__, "REMOTE_SCRIPT::Reload() %s reloaded successfully.\n");
+
return 0;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::PeriodicSend()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, RS::USER>::iterator it(authorizedUsers.begin());
while (it != authorizedUsers.end())
it != rsSettings.GetUserParams().end();
++it)
{
-// std::string parameter(GetUserParam(rsu.user, *it));
std::string parameter(rsu.user->GetParamValue(it->c_str()));
if (params.length() + parameter.length() > RS_PARAMS_LEN - 1)
+ {
+ logger("Script params string length %d exceeds the limit of %d symbols.", params.length() + parameter.length(), RS_PARAMS_LEN);
break;
+ }
params += parameter + " ";
}
strncpy((char *)packetTail.params, params.c_str(), RS_PARAMS_LEN);
//-----------------------------------------------------------------------------
std::vector<uint32_t> REMOTE_SCRIPT::IP2Routers(uint32_t ip)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
for (size_t i = 0; i < netRouters.size(); ++i)
{
if ((ip & netRouters[i].subnetMask) == (netRouters[i].subnetIP & netRouters[i].subnetMask))
RS::USER rsu(IP2Routers(user->GetCurrIP()), user);
Send(rsu);
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
authorizedUsers.insert(std::make_pair(user->GetCurrIP(), rsu));
}
//-----------------------------------------------------------------------------
void REMOTE_SCRIPT::DelRSU(USER_PTR user)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
-const std::map<uint32_t, RS::USER>::iterator it(
+STG_LOCKER lock(&mutex);
+std::map<uint32_t, RS::USER>::iterator it(authorizedUsers.begin());
+while (it != authorizedUsers.end())
+ {
+ if (it->second.user == user)
+ {
+ Send(it->second, true);
+ authorizedUsers.erase(it);
+ return;
+ }
+ ++it;
+ }
+/*const std::map<uint32_t, RS::USER>::iterator it(
authorizedUsers.find(user->GetCurrIP())
);
if (it != authorizedUsers.end())
{
Send(it->second, true);
authorizedUsers.erase(it);
- }
+ }*/
}
//-----------------------------------------------------------------------------
void RS::IP_NOTIFIER::Notify(const uint32_t & /*oldValue*/, const uint32_t & newValue)