--- /dev/null
+/*
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
+ */
+
+/*
+ $Revision: 1.5 $
+ $Date: 2010/03/04 11:57:11 $
+ $Author: faust $
+*/
+
+
+#ifndef STG_LOCKER_H
+#define STG_LOCKER_H
+
+#include <pthread.h>
+
+//-----------------------------------------------------------------------------
+class STG_LOCKER
+{
+public:
+ STG_LOCKER(pthread_mutex_t * m)
+ : mutex(m)
+ {
+ pthread_mutex_lock(mutex);
+ }
+
+ ~STG_LOCKER()
+ {
+ pthread_mutex_unlock(mutex);
+ }
+private:
+ STG_LOCKER(const STG_LOCKER & rvalue);
+ STG_LOCKER & operator=(const STG_LOCKER & rvalue);
+
+ pthread_mutex_t * mutex;
+};
+//-----------------------------------------------------------------------------
+
+#endif //STG_LOCKER_H
inline
void USER_PROPERTY<varT>::Set(const varT & rvalue)
{
-STG_LOCKER locker(&mutex, __FILE__, __LINE__);
+STG_LOCKER locker(&mutex);
typename std::set<PROPERTY_NOTIFIER_BASE<varT> *>::iterator ni;
inline
void USER_PROPERTY<varT>::AddBeforeNotifier(PROPERTY_NOTIFIER_BASE<varT> * n)
{
-STG_LOCKER locker(&mutex, __FILE__, __LINE__);
+STG_LOCKER locker(&mutex);
beforeNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
inline
void USER_PROPERTY<varT>::DelBeforeNotifier(const PROPERTY_NOTIFIER_BASE<varT> * n)
{
-STG_LOCKER locker(&mutex, __FILE__, __LINE__);
+STG_LOCKER locker(&mutex);
beforeNotifiers.erase(const_cast<PROPERTY_NOTIFIER_BASE<varT> *>(n));
}
//-----------------------------------------------------------------------------
inline
void USER_PROPERTY<varT>::AddAfterNotifier(PROPERTY_NOTIFIER_BASE<varT> * n)
{
-STG_LOCKER locker(&mutex, __FILE__, __LINE__);
+STG_LOCKER locker(&mutex);
afterNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
inline
void USER_PROPERTY<varT>::DelAfterNotifier(const PROPERTY_NOTIFIER_BASE<varT> * n)
{
-STG_LOCKER locker(&mutex, __FILE__, __LINE__);
+STG_LOCKER locker(&mutex);
afterNotifiers.erase(const_cast<PROPERTY_NOTIFIER_BASE<varT> *>(n));
}
//-----------------------------------------------------------------------------
STGLIBS = scriptexecuter \
conffiles \
logger \
- locker \
crypto \
common
printf "#############################################################################\n"
STG_LIBS="logger.lib
- locker.lib
crypto.lib
common.lib
scriptexecuter.lib
}
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
pending.push_back(data);
return false;
++it;
++count;
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
pending.erase(pending.begin(), it);
}
//-----------------------------------------------------------------------------
proto.cpp
STGLIBS = dotconfpp \
- locker \
crypto \
common
libs:
$(MAKE) -C $(DIR_LIBSRC)
-plugins: libs
+plugins: libs
$(MAKE) -C $(DIR_PLUGINS)
$(PROG): $(OBJS)
fi
if [ "$OS" = "unknown" ]
-then
+then
printf "################################################################################\n"
printf "# Sorry, but sgauthstress currently supported by Linux, FreeBSD 4.x-8.x #\n"
printf "################################################################################\n"
printf "#############################################################################\n"
STG_LIBS="logger.lib
- locker.lib
- crypto.lib
- common.lib
+ crypto.lib
+ common.lib
conffiles.lib
dotconfpp.lib"
void PROTO::AddUser(const USER & user, bool connect)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
users.push_back(std::make_pair(user.GetIP(), user));
users.back().second.InitNetwork();
bool PROTO::Connect(uint32_t ip)
{
std::list<std::pair<uint32_t, USER> >::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = std::find_if(users.begin(), users.end(), HasIP(ip));
if (it == users.end())
return false;
bool PROTO::Disconnect(uint32_t ip)
{
std::list<std::pair<uint32_t, USER> >::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = std::find_if(users.begin(), users.end(), HasIP(ip));
if (it == users.end())
return false;
{
int res;
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
res = poll(&pollFds.front(), pollFds.size(), timeout);
}
if (res < 0)
void PROTO::CheckTimeouts()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<std::pair<uint32_t, USER> >::iterator it;
for (it = users.begin(); it != users.end(); ++it)
{
bool result = true;
std::vector<struct pollfd>::iterator it;
std::list<std::pair<uint32_t, USER> >::iterator userIt;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
for (it = pollFds.begin(), userIt = users.begin(); it != pollFds.end() && userIt != users.end(); ++it, ++userIt)
{
if (it->revents)
STGLIBS = scriptexecuter \
dotconfpp \
- locker \
logger \
common
{
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
parent::iterator it(parent::begin());
while (it != parent::end())
inline
ACTIONS_LIST::parent::iterator ACTIONS_LIST::begin()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::begin();
}
inline
ACTIONS_LIST::parent::iterator ACTIONS_LIST::end()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::end();
}
inline
ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::begin() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::begin();
}
inline
ACTIONS_LIST::parent::const_iterator ACTIONS_LIST::end() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::end();
}
inline
bool ACTIONS_LIST::empty() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::empty();
}
inline
size_t ACTIONS_LIST::size() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return parent::size();
}
inline
void ACTIONS_LIST::swap(ACTIONS_LIST & list)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
parent::swap(list);
}
typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
DATA_TYPE d)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
push_back(new ACTION<ACTIVE_CLASS, DATA_TYPE>(ac, a, d));
}
inline
void ACTIONS_LIST::InvokeAll()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::for_each(
parent::begin(),
parent::end(),
//-----------------------------------------------------------------------------
int ADMINS_IMPL::Add(const string & login, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
//-----------------------------------------------------------------------------
int ADMINS_IMPL::Del(const string & login, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
ADMIN_IMPL adm(0, login, "");
const PRIV * priv = admin->GetPriv();
//-----------------------------------------------------------------------------
int ADMINS_IMPL::Change(const ADMIN_CONF & ac, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->adminChg)
//-----------------------------------------------------------------------------
int ADMINS_IMPL::Read()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
vector<string> adminsList;
if (store->GetAdminsList(&adminsList) < 0)
{
{
assert(admin != NULL && "Pointer to admin is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "No admin in system!\n");
//-----------------------------------------------------------------------------
bool ADMINS_IMPL::Exists(const string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
//-----------------------------------------------------------------------------
bool ADMINS_IMPL::Correct(const string & login, const std::string & password, ADMIN ** admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
//-----------------------------------------------------------------------------
int ADMINS_IMPL::OpenSearch() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = data.begin();
return handle;
//-----------------------------------------------------------------------------
int ADMINS_IMPL::SearchNext(int h, ADMIN_CONF * ac) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
WriteServLog("ADMINS. Incorrect search handle.");
//-----------------------------------------------------------------------------
int ADMINS_IMPL::CloseSearch(int h) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));
printf "#############################################################################\n"
STG_LIBS="logger.lib
- locker.lib
crypto.lib
common.lib
scriptexecuter.lib
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::Add(const CORP_CONF & corp, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::Del(const std::string & name, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::Change(const CORP_CONF & corp, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->corpChg)
//-----------------------------------------------------------------------------
bool CORPORATIONS_IMPL::Read()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::vector<std::string> corpsList;
if (store->GetCorpsList(&corpsList) < 0)
{
{
assert(corp != NULL && "Pointer to corporation is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
return false;
//-----------------------------------------------------------------------------
bool CORPORATIONS_IMPL::Exists(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::OpenSearch() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = data.begin();
return handle;
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::SearchNext(int h, CORP_CONF * corp) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
WriteServLog("CORPORATIONS. Incorrect search handle.");
//-----------------------------------------------------------------------------
int CORPORATIONS_IMPL::CloseSearch(int h) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));
while (_running)
{
{
- STG_LOCKER lock(&_mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&_mutex);
// Check for any actions...
if (empty())
{
// Double-checking technique
if (!_instance)
{
- STG_LOCKER lock(&singletonMutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&singletonMutex);
if (!_instance)
{
CreateInstance();
typename ACTOR<ACTIVE_CLASS, DATA_TYPE>::TYPE a,
DATA_TYPE d)
{
-STG_LOCKER lock(&_mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&_mutex);
// Add new action
ACTIONS_LIST::Enqueue(ac, a, d);
// Signal about new action
STGLIBS = scriptexecuter \
logger \
- locker \
common
include ../../Makefile.in
STGLIBS = common \
crypto \
logger \
- locker \
scriptexecuter
include ../../Makefile.in
//-----------------------------------------------------------------------------
int AUTH_IA::Timeouter()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, IA_USER>::iterator it;
it = ip2user.begin();
std::string login(user->GetLogin());
const size_t offset = LOGIN_LEN + 2 + 6; // LOGIN_LEN + sizeOfMagic + sizeOfVer;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, IA_USER>::iterator it(ip2user.find(sip));
if (it == ip2user.end())
std::map<uint32_t, IA_USER>::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = ip2user.find(ip);
if (it == ip2user.end())
{
std::map<uint32_t, IA_USER>::iterator it;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
it = ip2user.find(ip);
if (it == ip2user.end())
{
STGLIBS = common \
logger \
- locker \
scriptexecuter
include ../../Makefile.in
PROG = mod_cap_divert.so
-SRCS = ./divert_cap.cpp
+SRCS = ./divert_cap.cpp
LIBS += $(LIB_THREAD)
PROG = mod_cap_bpf.so
-SRCS = ./ether_cap.cpp
+SRCS = ./ether_cap.cpp
LIBS += $(LIB_THREAD)
endif
STGLIBS = common \
- locker \
logger \
scriptexecuter
$(LIB_THREAD)
STGLIBS = common \
- locker \
logger \
crypto \
scriptexecuter
STGLIBS = pinger \
common \
- locker \
logger \
scriptexecuter
//-----------------------------------------------------------------------------
int PING::Stop()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!isRunning)
return 0;
{
std::list<USER_PTR>::iterator iter = ping->usersList.begin();
{
- STG_LOCKER lock(&ping->mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&ping->mutex);
while (iter != ping->usersList.end())
{
if ((*iter)->GetProperty().ips.ConstData().OnlyOneIP())
//-----------------------------------------------------------------------------
void PING::GetUsers()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_PTR u;
int h = users->OpenSearch();
//-----------------------------------------------------------------------------
void PING::AddUser(USER_PTR u)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
SetUserNotifiers(u);
usersList.push_back(u);
//-----------------------------------------------------------------------------
void PING::DelUser(USER_PTR u)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
UnSetUserNotifiers(u);
STGLIBS = common \
crypto \
logger \
- locker \
scriptexecuter
include ../../Makefile.in
STGLIBS = common \
crypto \
- locker \
logger \
scriptexecuter
}
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "REMOTE_SCRIPT::Reload()\n");
//-----------------------------------------------------------------------------
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())
//-----------------------------------------------------------------------------
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__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, RS::USER>::iterator it(authorizedUsers.begin());
while (it != authorizedUsers.end())
{
STGLIBS = common \
smux \
logger \
- locker \
scriptexecuter
CFLAGS += -I ../../../../../stglibs/smux.lib/include/stg
STGLIBS = conffiles \
common \
- locker \
logger \
crypto
int ret = storeSettings.ParseSettings(settings);
if (ret)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = storeSettings.GetStrError();
}
return ret;
if (GetFileList(&files, storeSettings.GetUsersDir(), S_IFDIR, ""))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Failed to open '" + storeSettings.GetUsersDir() + "': " + std::string(strerror(errno));
return -1;
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
userList->swap(files);
if (GetFileList(&files, storeSettings.GetAdminsDir(), S_IFREG, ".adm"))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Failed to open '" + storeSettings.GetAdminsDir() + "': " + std::string(strerror(errno));
return -1;
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
adminList->swap(files);
if (GetFileList(&files, storeSettings.GetTariffsDir(), S_IFREG, ".tf"))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Failed to open '" + storeSettings.GetTariffsDir() + "': " + std::string(strerror(errno));
return -1;
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
tariffList->swap(files);
{
if (unlink(str.c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "unlink failed. Message: '";
errorStr += strerror(errno);
errorStr += "'";
if (rmdir(path))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "rmdir failed. Message: '";
errorStr += strerror(errno);
errorStr += "'";
if (mkdir(fileName.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == -1)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("mkdir failed. Message: '") + strerror(errno) + "'";
printfd(__FILE__, "FILES_STORE::AddUser - mkdir failed. Message: '%s'\n", strerror(errno));
return -1;
strprintf(&fileName, "%s%s/conf", storeSettings.GetUsersDir().c_str(), login.c_str());
if (Touch(fileName))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file \"" + fileName + "\'";
printfd(__FILE__, "FILES_STORE::AddUser - fopen failed. Message: '%s'\n", strerror(errno));
return -1;
strprintf(&fileName, "%s%s/stat", storeSettings.GetUsersDir().c_str(), login.c_str());
if (Touch(fileName))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file \"" + fileName + "\'";
printfd(__FILE__, "FILES_STORE::AddUser - fopen failed. Message: '%s'\n", strerror(errno));
return -1;
{
if (mkdir(dirName.c_str(), 0700) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Directory '" + dirName + "' cannot be created.";
printfd(__FILE__, "FILES_STORE::DelUser - mkdir failed. Message: '%s'\n", strerror(errno));
return -1;
strprintf(&dirName1, "%s/%s", storeSettings.GetUsersDir().c_str(), login.c_str());
if (rename(dirName1.c_str(), dirName.c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error moving dir from " + dirName1 + " to " + dirName;
printfd(__FILE__, "FILES_STORE::DelUser - rename failed. Message: '%s'\n", strerror(errno));
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - conf read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadString("Password", &conf->password, "") < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter Password.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - password read failed for user '%s'\n", login.c_str());
return -1;
}
if (conf->password.empty())
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' password is blank.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - password is blank for user '%s'\n", login.c_str());
return -1;
if (cf.ReadString("tariff", &conf->tariffName, "") < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter Tariff.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - tariff read failed for user '%s'\n", login.c_str());
return -1;
}
if (conf->tariffName.empty())
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' tariff is blank.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - tariff is blank for user '%s'\n", login.c_str());
return -1;
}
catch (const std::string & s)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
printfd(__FILE__, "FILES_STORE::RestoreUserConf - ip read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadInt("alwaysOnline", &conf->alwaysOnline, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter AlwaysOnline.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - alwaysonline read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadInt("down", &conf->disabled, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter Down.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - down read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadInt("passive", &conf->passive, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter Passive.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - passive read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadDouble("Credit", &conf->credit, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' data not read. Parameter Credit.";
printfd(__FILE__, "FILES_STORE::RestoreUserConf - credit read failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Cannot open file " + fileName + ".";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - stat read failed for user '%s'\n", login.c_str());
return -1;
snprintf(s, 22, "D%d", i);
if (cf.ReadULongLongInt(s, &traff, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter " + std::string(s);
printfd(__FILE__, "FILES_STORE::RestoreUserStat - download stat read failed for user '%s'\n", login.c_str());
return -1;
snprintf(s, 22, "U%d", i);
if (cf.ReadULongLongInt(s, &traff, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter " + std::string(s);
printfd(__FILE__, "FILES_STORE::RestoreUserStat - upload stat read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadDouble("Cash", &stat->cash, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter Cash";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - cash read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadDouble("FreeMb", &stat->freeMb, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter FreeMb";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - freemb read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadTime("LastCashAddTime", &stat->lastCashAddTime, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter LastCashAddTime";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - lastcashaddtime read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadTime("PassiveTime", &stat->passiveTime, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter PassiveTime";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - passivetime read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadDouble("LastCashAdd", &stat->lastCashAdd, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter LastCashAdd";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - lastcashadd read failed for user '%s'\n", login.c_str());
return -1;
if (cf.ReadTime("LastActivityTime", &stat->lastActivityTime, 0) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "User \'" + login + "\' stat not read. Parameter LastActivityTime";
printfd(__FILE__, "FILES_STORE::RestoreUserStat - lastactivitytime read failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("User \'") + login + "\' conf not written\n";
printfd(__FILE__, "FILES_STORE::SaveUserConf - conf write failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::SaveUserConf - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("User \'") + login + "\' stat not written\n";
printfd(__FILE__, "FILES_STORE::SaveUserStat - stat write failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::SaveUserStat - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
}
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot open \'" + fileName + "\'";
printfd(__FILE__, "FILES_STORE::WriteLogString - log write failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteLogString - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
}
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot open \'" + fileName + "\'";
printfd(__FILE__, "FILES_STORE::WriteLogString - log write failed for user '%s'\n", login.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteLogString - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
if (s.Error())
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file '" + stat1 + "'";
printfd(__FILE__, "FILES_STORE::SaveMonthStat - month stat write failed for user '%s'\n", login.c_str());
return -1;
if (s2.Error())
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file '" + stat2 + "'";
printfd(__FILE__, "FILES_STORE::SaveMonthStat - month stat write failed for user '%s'\n", login.c_str());
return -1;
if (Touch(fileName))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file " + fileName;
printfd(__FILE__, "FILES_STORE::AddAdmin - failed to add admin '%s'\n", login.c_str());
return -1;
strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), login.c_str());
if (unlink(fileName.c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "unlink failed. Message: '";
errorStr += strerror(errno);
errorStr += "'";
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot write admin " + ac.login + ". " + fileName;
printfd(__FILE__, "FILES_STORE::SaveAdmin - failed to save admin '%s'\n", ac.login.c_str());
return -1;
if (cf.Error())
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot open " + fileName;
printfd(__FILE__, "FILES_STORE::RestoreAdmin - failed to restore admin '%s'\n", ac->login.c_str());
return -1;
if (cf.ReadString("password", &p, "*"))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter password";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - password read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.userConf = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgConf";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgconf read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.userPasswd = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgPassword";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgpassword read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.userStat = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgStat";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgstat read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.userCash = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgCash";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgcash read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.userAddDel = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter UsrAddDel";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - usradddel read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.adminChg = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgAdmin";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgadmin read failed for admin '%s'\n", ac->login.c_str());
return -1;
ac->priv.tariffChg = a;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error in parameter ChgTariff";
printfd(__FILE__, "FILES_STORE::RestoreAdmin - chgtariff read failed for admin '%s'\n", ac->login.c_str());
return -1;
strprintf(&fileName, "%s/%s.tf", storeSettings.GetTariffsDir().c_str(), name.c_str());
if (Touch(fileName))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot create file " + fileName;
printfd(__FILE__, "FILES_STORE::AddTariff - failed to add tariff '%s'\n", name.c_str());
return -1;
strprintf(&fileName, "%s/%s.tf", storeSettings.GetTariffsDir().c_str(), name.c_str());
if (unlink(fileName.c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "unlink failed. Message: '";
errorStr += strerror(errno);
errorStr += "'";
if (conf.Error() != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read file " + fileName;
printfd(__FILE__, "FILES_STORE::RestoreTariff - failed to read tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "Time%d", i);
if (conf.ReadString(param, &str, "00:00-00:00") < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - time%d read failed for tariff '%s'\n", i, tariffName.c_str());
return -1;
strprintf(¶m, "PriceDayA%d", i);
if (conf.ReadDouble(param, &td->dirPrice[i].priceDayA, 0.0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - pricedaya read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "PriceDayB%d", i);
if (conf.ReadDouble(param, &td->dirPrice[i].priceDayB, 0.0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - pricedayb read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "PriceNightA%d", i);
if (conf.ReadDouble(param, &td->dirPrice[i].priceNightA, 0.0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - pricenighta read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "PriceNightB%d", i);
if (conf.ReadDouble(param, &td->dirPrice[i].priceNightB, 0.0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - pricenightb read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "Threshold%d", i);
if (conf.ReadInt(param, &td->dirPrice[i].threshold, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - threshold read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "SinglePrice%d", i);
if (conf.ReadInt(param, &td->dirPrice[i].singlePrice, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - singleprice read failed for tariff '%s'\n", tariffName.c_str());
return -1;
strprintf(¶m, "NoDiscount%d", i);
if (conf.ReadInt(param, &td->dirPrice[i].noDiscount, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter " + param;
printfd(__FILE__, "FILES_STORE::RestoreTariff - nodiscount read failed for tariff '%s'\n", tariffName.c_str());
return -1;
if (conf.ReadDouble("Fee", &td->tariffConf.fee, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter Fee";
printfd(__FILE__, "FILES_STORE::RestoreTariff - fee read failed for tariff '%s'\n", tariffName.c_str());
return -1;
if (conf.ReadDouble("Free", &td->tariffConf.free, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter Free";
printfd(__FILE__, "FILES_STORE::RestoreTariff - free read failed for tariff '%s'\n", tariffName.c_str());
return -1;
if (conf.ReadDouble("PassiveCost", &td->tariffConf.passiveCost, 0) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter PassiveCost";
printfd(__FILE__, "FILES_STORE::RestoreTariff - passivecost read failed for tariff '%s'\n", tariffName.c_str());
return -1;
if (conf.ReadString("TraffType", &str, "") < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType";
printfd(__FILE__, "FILES_STORE::RestoreTariff - trafftype read failed for tariff '%s'\n", tariffName.c_str());
return -1;
td->tariffConf.traffType = TRAFF_MAX;
else
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read tariff " + tariffName + ". Parameter TraffType incorrect";
printfd(__FILE__, "FILES_STORE::RestoreTariff - invalid trafftype for tariff '%s'\n", tariffName.c_str());
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error writing tariff " + tariffName;
printfd(__FILE__, "FILES_STORE::RestoreTariff - failed to save tariff '%s'\n", tariffName.c_str());
return e;
{
if (mkdir(dn, 0700) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Directory \'" + std::string(dn) + "\' cannot be created.";
printfd(__FILE__, "FILES_STORE::WriteDetailStat - mkdir failed. Message: '%s'\n", strerror(errno));
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteDetailStat - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
{
if (mkdir(dn, 0700) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Directory \'" + std::string(dn) + "\' cannot be created.";
printfd(__FILE__, "FILES_STORE::WriteDetailStat - mkdir failed. Message: '%s'\n", strerror(errno));
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteDetailStat - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
{
if (mkdir(dn, 0700) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Directory \'" + std::string(dn) + "\' cannot be created.";
printfd(__FILE__, "FILES_STORE::WriteDetailStat - mkdir failed. Message: '%s'\n", strerror(errno));
return -1;
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteDetailStat - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
if (!statFile)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "File \'" + std::string(fn) + "\' cannot be written.";
printfd(__FILE__, "FILES_STORE::WriteDetailStat - fopen failed. Message: '%s'\n", strerror(errno));
return -1;
if (fprintf(statFile, "-> %02d.%02d.%02d - %02d.%02d.%02d\n",
h1, m1, s1, h2, m2, s2) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("fprint failed. Message: '") + strerror(errno) + "'";
printfd(__FILE__, "FILES_STORE::WriteDetailStat - fprintf failed. Message: '%s'\n", strerror(errno));
fclose(statFile);
u.c_str(),
stIter->second.cash) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "fprint failed. Message: '";
errorStr += strerror(errno);
errorStr += "'";
u.c_str(),
stIter->second.cash) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("fprint failed. Message: '");
errorStr += strerror(errno);
errorStr += "'";
if (e)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
printfd(__FILE__, "FILES_STORE::WriteDetailStat - chmod/chown failed for user '%s'. Error: '%s'\n", login.c_str(), strerror(errno));
}
{
if (mkdir(dn.c_str(), 0700) != 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Directory \'";
errorStr += dn;
errorStr += "\' cannot be created.";
if (Touch(fn))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "File \'";
errorStr += fn;
errorStr += "\' cannot be writen.";
{
std::string idstr;
x2str(msg.header.id, idstr);
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Message for user \'";
errorStr += login + "\' with ID \'";
errorStr += idstr + "\' does not exist.";
msgFile = fopen((fileName + ".new").c_str(), "wt");
if (!msgFile)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "File \'" + fileName + "\' cannot be writen.";
printfd(__FILE__, "FILES_STORE::EditMessage - fopen failed. Message: '%s'\n", strerror(errno));
return -1;
if (!res)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("fprintf failed. Message: '") + strerror(errno) + "'";
printfd(__FILE__, "FILES_STORE::EditMessage - fprintf failed. Message: '%s'\n", strerror(errno));
fclose(msgFile);
if (rename((fileName + ".new").c_str(), fileName.c_str()) < 0)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Error moving dir from " + fileName + ".new to " + fileName;
printfd(__FILE__, "FILES_STORE::EditMessage - rename failed. Message: '%s'\n", strerror(errno));
return -1;
{
if (unlink((dn + messages[i]).c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("unlink failed. Message: '") + strerror(errno) + "'";
printfd(__FILE__, "FILES_STORE::GetMessageHdrs - unlink failed. Message: '%s'\n", strerror(errno));
return -1;
{
if (unlink((dn + messages[i]).c_str()))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = std::string("unlink failed. Message: '") + strerror(errno) + "'";
printfd(__FILE__, "FILES_STORE::GetMessageHdrs - unlink failed. Message: '%s'\n", strerror(errno));
return -1;
msgFile = fopen(fileName.c_str(), "rt");
if (!msgFile)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "File \'";
errorStr += fileName;
errorStr += "\' cannot be openned.";
for (int pos = 0; pos < 6; pos++)
{
if (fgets(p, sizeof(p) - 1, msgFile) == NULL) {
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read file \'";
errorStr += fileName;
errorStr += "\'. Missing data.";
if (feof(msgFile))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read file \'";
errorStr += fileName;
errorStr += "\'. Missing data.";
if (str2x(p, *(d[pos])))
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
errorStr = "Cannot read file \'";
errorStr += fileName;
errorStr += "\'. Incorrect value. \'";
STGLIBS = ibpp \
common \
- locker \
logger \
crypto
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetAdminsList(vector<string> * adminsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::SaveAdmin(const ADMIN_CONF & ac) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::RestoreAdmin(ADMIN_CONF * ac, const string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddAdmin(const string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelAdmin(const string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetCorpsList(std::vector<std::string> * corpsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::SaveCorp(const CORP_CONF & cc) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::RestoreCorp(CORP_CONF * cc, const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddCorp(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelCorp(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddMessage(STG_MSG * msg, const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::EditMessage(const STG_MSG & msg,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
STG_MSG * msg,
const std::string &) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelMessage(uint64_t id, const std::string &) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::GetMessageHdrs(std::vector<STG_MSG_HDR> * hdrsList,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetServicesList(std::vector<std::string> * servicesList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::SaveService(const SERVICE_CONF & sc) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::RestoreService(SERVICE_CONF * sc,
const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetTariffsList(std::vector<std::string> * tariffsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddTariff(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelTariff(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::SaveTariff(const TARIFF_DATA & td,
const std::string & tariffName) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::RestoreTariff(TARIFF_DATA * td,
const std::string & tariffName) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::GetUsersList(std::vector<std::string> * usersList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::AddUser(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::DelUser(const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::SaveUserStat(const USER_STAT & stat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return SaveStat(stat, login);
}
int FIREBIRD_STORE::SaveUserConf(const USER_CONF & conf,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::RestoreUserStat(USER_STAT * stat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
int FIREBIRD_STORE::RestoreUserConf(USER_CONF * conf,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amRead, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
const std::string & newValue,
const std::string & message = "") const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::WriteUserConnect(const std::string & login, uint32_t ip) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
double /*freeMb*/,
const std::string & /*reason*/) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
time_t lastStat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
//-----------------------------------------------------------------------------
int FIREBIRD_STORE::SaveMonthStat(const USER_STAT & stat, int month, int year, const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
IBPP::Transaction tr = IBPP::TransactionFactory(db, IBPP::amWrite, til, tlr);
IBPP::Statement st = IBPP::StatementFactory(db, tr);
STGLIBS = common \
crypto \
- locker \
logger
PG_CFLAGS = $(shell pg_config --includedir)
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetAdminsList(std::vector<std::string> * adminsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::SaveAdmin(const ADMIN_CONF & ac) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::RestoreAdmin(ADMIN_CONF * ac, const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddAdmin(const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelAdmin(const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetCorpsList(std::vector<std::string> * corpsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::SaveCorp(const CORP_CONF & cc) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::RestoreCorp(CORP_CONF * cc, const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddCorp(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelCorp(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddMessage(STG_MSG * msg, const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::EditMessage(const STG_MSG & msg,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
STG_MSG * msg,
const std::string &) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelMessage(uint64_t id, const std::string &) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::GetMessageHdrs(std::vector<STG_MSG_HDR> * hdrsList,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetServicesList(std::vector<std::string> * servicesList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::SaveService(const SERVICE_CONF & sc) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::RestoreService(SERVICE_CONF * sc,
const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelService(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetTariffsList(std::vector<std::string> * tariffsList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddTariff(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelTariff(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::SaveTariff(const TARIFF_DATA & td,
const std::string & tariffName) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::RestoreTariff(TARIFF_DATA * td,
const std::string & tariffName) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::GetUsersList(std::vector<std::string> * usersList) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::AddUser(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::DelUser(const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::SaveUserStat(const USER_STAT & stat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return SaveStat(stat, login);
}
int POSTGRESQL_STORE::SaveUserConf(const USER_CONF & conf,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::RestoreUserStat(USER_STAT * stat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
int POSTGRESQL_STORE::RestoreUserConf(USER_CONF * conf,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
const std::string & newValue,
const std::string & message = "") const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::WriteUserConnect(const std::string & login, uint32_t ip) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
double freeMb,
const std::string & reason) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
time_t lastStat,
const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (PQstatus(connection) != CONNECTION_OK)
{
//-----------------------------------------------------------------------------
int POSTGRESQL_STORE::SaveMonthStat(const USER_STAT & stat, int month, int year, const std::string & login) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return SaveStat(stat, login, year, month);
}
//-----------------------------------------------------------------------------
int SERVICES_IMPL::Add(const SERVICE_CONF & service, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
//-----------------------------------------------------------------------------
int SERVICES_IMPL::Del(const std::string & name, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
//-----------------------------------------------------------------------------
int SERVICES_IMPL::Change(const SERVICE_CONF & service, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->serviceChg)
//-----------------------------------------------------------------------------
bool SERVICES_IMPL::Read()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::vector<std::string> servicesList;
if (store->GetServicesList(&servicesList) < 0)
{
{
assert(service != NULL && "Pointer to service is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
return false;
//-----------------------------------------------------------------------------
bool SERVICES_IMPL::Exists(const std::string & name) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (data.empty())
{
printfd(__FILE__, "no admin in system!\n");
//-----------------------------------------------------------------------------
int SERVICES_IMPL::OpenSearch() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = data.begin();
return handle;
//-----------------------------------------------------------------------------
int SERVICES_IMPL::SearchNext(int h, SERVICE_CONF * service) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
WriteServLog("SERVICES. Incorrect search handle.");
//-----------------------------------------------------------------------------
int SERVICES_IMPL::CloseSearch(int h) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));
//-----------------------------------------------------------------------------
int TARIFFS_IMPL::ReadTariffs()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
vector<string> tariffsList;
if (store->GetTariffsList(&tariffsList))
//-----------------------------------------------------------------------------
size_t TARIFFS_IMPL::Count() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
return tariffs.size();
}
//-----------------------------------------------------------------------------
if (name == NO_TARIFF_NAME)
return &noTariff;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
list<TARIFF_IMPL>::const_iterator ti;
ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
return -1;
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
list<TARIFF_IMPL>::iterator ti;
ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name));
TARIFF_DATA td;
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
list<TARIFF_IMPL>::iterator ti;
ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
}
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
list<TARIFF_IMPL>::iterator ti;
ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name));
void TARIFFS_IMPL::GetTariffsData(std::list<TARIFF_DATA> * tdl)
{
assert(tdl != NULL && "Tariffs data list is not null");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
Tariffs::const_iterator it = tariffs.begin();
for (; it != tariffs.end(); ++it)
//-----------------------------------------------------------------------------
void TARIFFS_IMPL::AddNotifierAdd(NOTIFIER_BASE<TARIFF_DATA> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
void TARIFFS_IMPL::DelNotifierAdd(NOTIFIER_BASE<TARIFF_DATA> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
void TARIFFS_IMPL::AddNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
void TARIFFS_IMPL::DelNotifierDel(NOTIFIER_BASE<TARIFF_DATA> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
int TRAFFCOUNTER_IMPL::Start()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!stopped)
return 0;
TouchFile(monFile.c_str());
}
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
//printfd(__FILE__, "TRAFFCOUNTER::Process()\n");
//TODO replace find with lower_bound.
//-----------------------------------------------------------------------------
void TRAFFCOUNTER_IMPL::FlushAndRemove()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
Packets::size_type oldPacketsSize = packets.size();
Index::size_type oldIp2packetsSize = ip2packets.size();
uint32_t uip = user->GetCurrIP();
std::pair<ip2p_iter, ip2p_iter> pi;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
// Find all packets with IP belongs to this user
pi = ip2packets.equal_range(uip);
printfd(__FILE__, "DelUser: %s \n", inet_ntostring(uip).c_str());
std::pair<ip2p_iter, ip2p_iter> pi;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
pi = ip2packets.equal_range(uip);
while (pi.first != pi.second)
//-----------------------------------------------------------------------------
int TRAFFCOUNTER_IMPL::Reload()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (ReadRules(true))
{
//-----------------------------------------------------------------------------
void USER_IMPL::SetLogin(const std::string & l)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
assert(login.empty() && "Login is already set");
login = l;
id = userIDGenerator.GetNextID();
//-----------------------------------------------------------------------------
int USER_IMPL::ReadConf()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_CONF conf;
if (store->RestoreUserConf(&conf, login))
//-----------------------------------------------------------------------------
int USER_IMPL::ReadStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_STAT stat;
if (store->RestoreUserStat(&stat, login))
//-----------------------------------------------------------------------------
int USER_IMPL::WriteConf()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_CONF conf(property.GetConf());
printfd(__FILE__, "USER::WriteConf()\n");
//-----------------------------------------------------------------------------
int USER_IMPL::WriteStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
USER_STAT stat(property.GetStat());
if (store->SaveUserStat(stat, login))
//-----------------------------------------------------------------------------
int USER_IMPL::WriteMonthStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
time_t tt = stgTime - 3600;
struct tm t1;
localtime_r(&tt, &t1);
//-----------------------------------------------------------------------------
int USER_IMPL::Authorize(uint32_t ip, uint32_t dirs, const AUTH * auth)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
/*
* Authorize user. It only means that user will be authorized. Nothing more.
* User can be connected or disconnected while authorized.
//-----------------------------------------------------------------------------
void USER_IMPL::Unauthorize(const AUTH * auth, const std::string & reason)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
/*
* Authorizer tries to unauthorize user, that was not authorized by it
*/
//-----------------------------------------------------------------------------
bool USER_IMPL::IsAuthorizedBy(const AUTH * auth) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
// Is this user authorized by specified authorizer?
return authorizedBy.find(auth) != authorizedBy.end();
}
* Connect user to Internet. This function is differ from Authorize() !!!
*/
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!fakeConnect)
{
* Disconnect user from Internet. This function is differ from UnAuthorize() !!!
*/
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!lastIPForDisconnect)
{
void USER_IMPL::PrintUser() const
{
//return;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::cout << "============================================================" << std::endl;
std::cout << "id=" << id << std::endl;
std::cout << "login=" << login << std::endl;
//-----------------------------------------------------------------------------
void USER_IMPL::Run()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (stgTime > static_cast<time_t>(lastWriteStat + settings->GetStatWritePeriod()))
{
//-----------------------------------------------------------------------------
void USER_IMPL::UpdatePingTime(time_t t)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
//printfd(__FILE__, "UpdatePingTime(%d) %s\n", t, login.c_str());
if (t)
pingTime = t;
//-----------------------------------------------------------------------------
bool USER_IMPL::IsInetable()
{
-//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+//STG_LOCKER lock(&mutex);
if (disabled || passive)
return false;
//-----------------------------------------------------------------------------
std::string USER_IMPL::GetEnabledDirs() const
{
-//STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+//STG_LOCKER lock(&mutex);
std::string dirs = "";
for(int i = 0; i < DIR_NUM; i++)
void USER_IMPL::AddTraffStatU(int dir, uint32_t ip, uint32_t len)
#endif
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!connected || tariff == NULL)
return;
void USER_IMPL::AddTraffStatD(int dir, uint32_t ip, uint32_t len)
#endif
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (!connected || tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::AddCurrIPBeforeNotifier(CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.AddBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelCurrIPBeforeNotifier(const CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.DelBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddCurrIPAfterNotifier(CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.AddAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelCurrIPAfterNotifier(const CURR_IP_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
currIP.DelAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddConnectedBeforeNotifier(CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.AddBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelConnectedBeforeNotifier(const CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.DelBeforeNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::AddConnectedAfterNotifier(CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.AddAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::DelConnectedAfterNotifier(const CONNECTED_NOTIFIER * notifier)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
connected.DelAfterNotifier(notifier);
}
//-----------------------------------------------------------------------------
void USER_IMPL::OnAdd()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::string scriptOnAdd = settings->GetScriptsDir() + "/OnUserAdd";
//-----------------------------------------------------------------------------
void USER_IMPL::OnDelete()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::string scriptOnDel = settings->GetScriptsDir() + "/OnUserDel";
TRAFF_STAT ts;
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
ts.swap(traffStat);
}
if (!hard)
{
printfd(__FILE__, "USER::WriteDetailStat() - pushing detail stat to queue\n");
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
traffStatSaved.second.swap(ts);
traffStatSaved.first = lastWriteDetailedStat;
}
//-----------------------------------------------------------------------------
double USER_IMPL::GetPassiveTimePart() const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
static int daysInMonth[12] =
{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
//-----------------------------------------------------------------------------
void USER_IMPL::SetPassiveTimeAsNewUser()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
time_t t = stgTime;
struct tm tm;
//-----------------------------------------------------------------------------
void USER_IMPL::MidnightResetSessionStat()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (connected)
{
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessNewMonth()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
// Reset traff
if (connected)
{
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDayFeeSpread()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (passive.ConstData() || tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDayFee()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (tariff == NULL)
return;
//-----------------------------------------------------------------------------
void USER_IMPL::ProcessDailyFee()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (passive.ConstData() || tariff == NULL)
return;
//-----------------------------------------------------------------------------
int USER_IMPL::AddMessage(STG_MSG * msg)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (SendMessage(*msg))
{
//-----------------------------------------------------------------------------
int USERS_IMPL::FindByName(const std::string & login, USER_PTR * user)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
user_iter u;
if (FindByNameNonLock(login, &u))
return -1;
//-----------------------------------------------------------------------------
int USERS_IMPL::FindByName(const std::string & login, CONST_USER_PTR * user) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const_user_iter u;
if (FindByNameNonLock(login, &u))
return -1;
//-----------------------------------------------------------------------------
bool USERS_IMPL::TariffInUse(const std::string & tariffName) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<USER_IMPL>::const_iterator iter;
iter = users.begin();
while (iter != users.end())
//-----------------------------------------------------------------------------
int USERS_IMPL::Add(const std::string & login, const ADMIN * admin)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const PRIV * priv = admin->GetPriv();
if (!priv->userAddDel)
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
if (FindByNameNonLock(login, &u))
{
}
{
- STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+ STG_LOCKER lock(&mutex);
u->OnDelete();
uint32_t enabledDirs, const AUTH * auth)
{
user_iter iter;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (FindByNameNonLock(login, &iter))
{
WriteServLog("Attempt to authorize non-existant user '%s'", login.c_str());
const std::string & reason)
{
user_iter iter;
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (FindByNameNonLock(login, &iter))
{
WriteServLog("Attempt to unauthorize non-existant user '%s'", login.c_str());
//-----------------------------------------------------------------------------
void USERS_IMPL::RealDelUser()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
printfd(__FILE__, "RealDelUser() users to del: %d\n", usersToDelete.size());
if (!ip)
return; // User has disconnected
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const std::map<uint32_t, user_iter>::iterator it(
ipIndex.lower_bound(ip)
printfd(__FILE__, "USERS: Del IP Idx\n");
assert(ip && "User has non-null ip");
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
const std::map<uint32_t, user_iter>::iterator it(
ipIndex.find(ip)
//-----------------------------------------------------------------------------
int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_PTR * usr) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
//-----------------------------------------------------------------------------
int USERS_IMPL::FindByIPIdx(uint32_t ip, USER_IMPL ** usr) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
user_iter iter;
if (FindByIPIdx(ip, iter))
//-----------------------------------------------------------------------------
bool USERS_IMPL::IsIPInIndex(uint32_t ip) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::map<uint32_t, user_iter>::const_iterator it(ipIndex.find(ip));
//-----------------------------------------------------------------------------
bool USERS_IMPL::IsIPInUse(uint32_t ip, const std::string & login, CONST_USER_PTR * user) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<USER_IMPL>::const_iterator iter;
iter = users.begin();
while (iter != users.end())
//-----------------------------------------------------------------------------
void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE<USER_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE<USER_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE<USER_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiers.insert(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE<USER_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiers.erase(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiersImpl.insert(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE<USER_IMPL_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onAddNotifiersImpl.erase(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiersImpl.insert(n);
}
//-----------------------------------------------------------------------------
void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE<USER_IMPL_PTR> * n)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
onDelNotifiersImpl.erase(n);
}
//-----------------------------------------------------------------------------
int USERS_IMPL::OpenSearch()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
handle++;
searchDescriptors[handle] = users.begin();
return handle;
//-----------------------------------------------------------------------------
int USERS_IMPL::SearchNext(int h, USER_IMPL ** user)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) == searchDescriptors.end())
{
//-----------------------------------------------------------------------------
int USERS_IMPL::CloseSearch(int h)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
if (searchDescriptors.find(h) != searchDescriptors.end())
{
searchDescriptors.erase(searchDescriptors.find(h));
//-----------------------------------------------------------------------------
void USERS_IMPL::AddUserIntoIndexes(user_iter user)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
loginIndex.insert(make_pair(user->GetLogin(), user));
}
//-----------------------------------------------------------------------------
void USERS_IMPL::DelUserFromIndexes(user_iter user)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
loginIndex.erase(user->GetLogin());
}
//-----------------------------------------------------------------------------
+++ /dev/null
-###############################################################################
-# $Id: Makefile,v 1.2 2008/12/04 17:11:55 faust Exp $
-###############################################################################
-
-LIB_NAME = stglocker
-
-SRCS = locker.cpp
-
-INCS = locker.h
-
-LIBS = $(LIB_THREAD)
-
-include ../Makefile.in
+++ /dev/null
-/*
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
-/*
- $Revision: 1.5 $
- $Date: 2010/03/04 11:57:11 $
- $Author: faust $
-*/
-
-
-#ifndef STG_LOCKER_H
-#define STG_LOCKER_H
-
-#include <pthread.h>
-
-#ifdef DEBUG_LOCKER
-
-#include <iostream>
-#include <string>
-#include <pthread.h>
-
-#endif
-
-//-----------------------------------------------------------------------------
-class STG_LOCKER
-{
-public:
- #ifdef DEBUG_LOCKER
- STG_LOCKER(pthread_mutex_t * m, const char * __file__, int __line__)
- : mutex(m),
- file(__file__),
- line(__line__),
- lockerMutex(),
- lockID(0)
- #else
- STG_LOCKER(pthread_mutex_t * m, const char *, int)
- : mutex(m)
- #endif
- {
- mutex = m;
- #ifdef DEBUG_LOCKER
- pthread_mutex_lock(&lockerMutex);
- file = __file__;
- line = __line__;
- if (id == 0)
- pthread_mutex_init(&lockerMutex, NULL);
-
- lockID = ++id;
- std::cout << "Lock: " << lockID << " " << file << ":" << line << " " << mutex << " " << pthread_self() << std::endl;
- pthread_mutex_unlock(&lockerMutex);
- #endif
- pthread_mutex_lock(mutex);
- }
-
- ~STG_LOCKER()
- {
- pthread_mutex_unlock(mutex);
- #ifdef DEBUG_LOCKER
- pthread_mutex_lock(&lockerMutex);
- std::cout << "Unlock: " << lockID << " " << file << ":" << line << " " << mutex << " " << pthread_self() << std::endl;
- pthread_mutex_unlock(&lockerMutex);
- #endif
- }
-private:
- STG_LOCKER(const STG_LOCKER & rvalue);
- STG_LOCKER & operator=(const STG_LOCKER & rvalue);
-
- pthread_mutex_t * mutex;
- #ifdef DEBUG_LOCKER
- std::string file;
- int line;
- static pthread_mutex_t lockerMutex;
- static long long id;
- long long lockID;
- #endif
-};
-//-----------------------------------------------------------------------------
-
-#endif //STG_LOCKER_H
+++ /dev/null
-/*
- * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-/*
- * Author : Boris Mikhailenko <stg34@stargazer.dp.ua>
- */
-
-/*
- $Revision: 1.2 $
- $Date: 2007/11/30 08:57:49 $
- $Author: nobunaga $
-*/
-
-#ifdef DEBUG_LOCKER
-
-#include <pthread.h>
-
-#include "stg/locker.h"
-
-long long STG_LOCKER::id = 0;
-pthread_mutex_t STG_LOCKER::lockerMutex = PTHREAD_MUTEX_INITIALIZER;
-
-#endif
-
//-----------------------------------------------------------------------------
void STG_PINGER::AddIP(uint32_t ip)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
ipToAdd.push_back(ip);
}
//-----------------------------------------------------------------------------
void STG_PINGER::DelIP(uint32_t ip)
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
ipToDel.push_back(ip);
}
//-----------------------------------------------------------------------------
void STG_PINGER::RealAddIP()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<uint32_t>::iterator iter;
iter = ipToAdd.begin();
//-----------------------------------------------------------------------------
void STG_PINGER::RealDelIP()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::list<uint32_t>::iterator iter;
std::multimap<uint32_t, time_t>::iterator treeIter;
//-----------------------------------------------------------------------------
void STG_PINGER::PrintAllIP()
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::multimap<uint32_t, time_t>::iterator iter;
iter = pingIP.begin();
while (iter != pingIP.end())
//-----------------------------------------------------------------------------
int STG_PINGER::GetIPTime(uint32_t ip, time_t * t) const
{
-STG_LOCKER lock(&mutex, __FILE__, __LINE__);
+STG_LOCKER lock(&mutex);
std::multimap<uint32_t, time_t>::const_iterator treeIter;
treeIter = pingIP.find(ip);
size = st->size;
- if((size == 4)) {
+ if(size == 4) {
/* Constraint check succeeded */
return 0;
} else {