From: Maxim Mamontov Date: Mon, 9 Jun 2014 09:16:49 +0000 (+0300) Subject: Simplified STG_LOCKER. X-Git-Url: https://git.stg.codes/stg.git/commitdiff_plain/c3d4d096451b5c683492e81574b302e5486950e1 Simplified STG_LOCKER. --- diff --git a/include/stg/locker.h b/include/stg/locker.h new file mode 100644 index 00000000..fe1014d7 --- /dev/null +++ b/include/stg/locker.h @@ -0,0 +1,55 @@ +/* + * 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 + */ + +/* + $Revision: 1.5 $ + $Date: 2010/03/04 11:57:11 $ + $Author: faust $ +*/ + + +#ifndef STG_LOCKER_H +#define STG_LOCKER_H + +#include + +//----------------------------------------------------------------------------- +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 diff --git a/include/stg/user_property.h b/include/stg/user_property.h index 97c1af51..824c668e 100644 --- a/include/stg/user_property.h +++ b/include/stg/user_property.h @@ -214,7 +214,7 @@ template inline void USER_PROPERTY::Set(const varT & rvalue) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); +STG_LOCKER locker(&mutex); typename std::set *>::iterator ni; @@ -244,7 +244,7 @@ template inline void USER_PROPERTY::AddBeforeNotifier(PROPERTY_NOTIFIER_BASE * n) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); +STG_LOCKER locker(&mutex); beforeNotifiers.insert(n); } //----------------------------------------------------------------------------- @@ -252,7 +252,7 @@ template inline void USER_PROPERTY::DelBeforeNotifier(const PROPERTY_NOTIFIER_BASE * n) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); +STG_LOCKER locker(&mutex); beforeNotifiers.erase(const_cast *>(n)); } //----------------------------------------------------------------------------- @@ -260,7 +260,7 @@ template inline void USER_PROPERTY::AddAfterNotifier(PROPERTY_NOTIFIER_BASE * n) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); +STG_LOCKER locker(&mutex); afterNotifiers.insert(n); } //----------------------------------------------------------------------------- @@ -268,7 +268,7 @@ template inline void USER_PROPERTY::DelAfterNotifier(const PROPERTY_NOTIFIER_BASE * n) { -STG_LOCKER locker(&mutex, __FILE__, __LINE__); +STG_LOCKER locker(&mutex); afterNotifiers.erase(const_cast *>(n)); } //----------------------------------------------------------------------------- diff --git a/projects/rscriptd/Makefile b/projects/rscriptd/Makefile index ce0b76dc..adbc4eb3 100644 --- a/projects/rscriptd/Makefile +++ b/projects/rscriptd/Makefile @@ -13,7 +13,6 @@ SRCS = ./main.cpp \ STGLIBS = scriptexecuter \ conffiles \ logger \ - locker \ crypto \ common diff --git a/projects/rscriptd/build b/projects/rscriptd/build index 5746d822..59927348 100755 --- a/projects/rscriptd/build +++ b/projects/rscriptd/build @@ -64,7 +64,6 @@ printf " Building rscriptd for $sys $release\n" printf "#############################################################################\n" STG_LIBS="logger.lib - locker.lib crypto.lib common.lib scriptexecuter.lib diff --git a/projects/rscriptd/listener.cpp b/projects/rscriptd/listener.cpp index 9fe4c0f0..cc2a0560 100644 --- a/projects/rscriptd/listener.cpp +++ b/projects/rscriptd/listener.cpp @@ -311,7 +311,7 @@ else if (packetHead.packetType == RS_DISCONNECT_PACKET) } } -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); pending.push_back(data); return false; @@ -411,7 +411,7 @@ while (it != pending.end() && count < 256) ++it; ++count; } -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); pending.erase(pending.begin(), it); } //----------------------------------------------------------------------------- diff --git a/projects/sgauthstress/Makefile b/projects/sgauthstress/Makefile index 4474e77f..f88e59c6 100644 --- a/projects/sgauthstress/Makefile +++ b/projects/sgauthstress/Makefile @@ -9,7 +9,6 @@ SRCS = main.cpp \ proto.cpp STGLIBS = dotconfpp \ - locker \ crypto \ common @@ -40,7 +39,7 @@ all: libs plugins $(PROG) ../../Makefile.conf libs: $(MAKE) -C $(DIR_LIBSRC) -plugins: libs +plugins: libs $(MAKE) -C $(DIR_PLUGINS) $(PROG): $(OBJS) diff --git a/projects/sgauthstress/build b/projects/sgauthstress/build index 825f00b5..676938ad 100755 --- a/projects/sgauthstress/build +++ b/projects/sgauthstress/build @@ -60,7 +60,7 @@ then fi if [ "$OS" = "unknown" ] -then +then printf "################################################################################\n" printf "# Sorry, but sgauthstress currently supported by Linux, FreeBSD 4.x-8.x #\n" printf "################################################################################\n" @@ -72,9 +72,8 @@ printf " Building sgauthstress for $sys $release\n" printf "#############################################################################\n" STG_LIBS="logger.lib - locker.lib - crypto.lib - common.lib + crypto.lib + common.lib conffiles.lib dotconfpp.lib" diff --git a/projects/sgauthstress/proto.cpp b/projects/sgauthstress/proto.cpp index 2fd03140..3150002d 100644 --- a/projects/sgauthstress/proto.cpp +++ b/projects/sgauthstress/proto.cpp @@ -134,7 +134,7 @@ return true; 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(); @@ -153,7 +153,7 @@ if (connect) bool PROTO::Connect(uint32_t ip) { std::list >::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; @@ -166,7 +166,7 @@ return RealConnect(&it->second); bool PROTO::Disconnect(uint32_t ip) { std::list >::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; @@ -182,7 +182,7 @@ while (running) { int res; { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); res = poll(&pollFds.front(), pollFds.size(), timeout); } if (res < 0) @@ -205,7 +205,7 @@ stopped = true; void PROTO::CheckTimeouts() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::list >::iterator it; for (it = users.begin(); it != users.end(); ++it) { @@ -230,7 +230,7 @@ bool PROTO::RecvPacket() bool result = true; std::vector::iterator it; std::list >::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) diff --git a/projects/stargazer/Makefile b/projects/stargazer/Makefile index aa2b6f90..1b109fef 100644 --- a/projects/stargazer/Makefile +++ b/projects/stargazer/Makefile @@ -26,7 +26,6 @@ SRCS = ./admin_impl.cpp \ STGLIBS = scriptexecuter \ dotconfpp \ - locker \ logger \ common diff --git a/projects/stargazer/actions.inl.h b/projects/stargazer/actions.inl.h index 1a810228..b5b3f8a5 100644 --- a/projects/stargazer/actions.inl.h +++ b/projects/stargazer/actions.inl.h @@ -26,7 +26,7 @@ ACTIONS_LIST::~ACTIONS_LIST() { { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); parent::iterator it(parent::begin()); while (it != parent::end()) @@ -41,49 +41,49 @@ pthread_mutex_destroy(&mutex); 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); } @@ -93,14 +93,14 @@ void ACTIONS_LIST::Enqueue(ACTIVE_CLASS & ac, typename ACTOR::TYPE a, DATA_TYPE d) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); push_back(new ACTION(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(), diff --git a/projects/stargazer/admins_impl.cpp b/projects/stargazer/admins_impl.cpp index 10d1108e..08656a49 100644 --- a/projects/stargazer/admins_impl.cpp +++ b/projects/stargazer/admins_impl.cpp @@ -57,7 +57,7 @@ Read(); //----------------------------------------------------------------------------- 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) @@ -96,7 +96,7 @@ return -1; //----------------------------------------------------------------------------- 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(); @@ -141,7 +141,7 @@ return 0; //----------------------------------------------------------------------------- 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) @@ -178,7 +178,7 @@ return 0; //----------------------------------------------------------------------------- int ADMINS_IMPL::Read() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); vector adminsList; if (store->GetAdminsList(&adminsList) < 0) { @@ -205,7 +205,7 @@ bool ADMINS_IMPL::Find(const string & l, ADMIN ** admin) { 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"); @@ -227,7 +227,7 @@ return true; //----------------------------------------------------------------------------- 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"); @@ -245,7 +245,7 @@ return false; //----------------------------------------------------------------------------- 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"); @@ -272,7 +272,7 @@ return true; //----------------------------------------------------------------------------- int ADMINS_IMPL::OpenSearch() const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); handle++; searchDescriptors[handle] = data.begin(); return handle; @@ -280,7 +280,7 @@ 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."); @@ -299,7 +299,7 @@ return 0; //----------------------------------------------------------------------------- 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)); diff --git a/projects/stargazer/build b/projects/stargazer/build index 12ec9d23..9875d0a4 100755 --- a/projects/stargazer/build +++ b/projects/stargazer/build @@ -92,7 +92,6 @@ printf " Building STG 2.4 for $sys $release\n" printf "#############################################################################\n" STG_LIBS="logger.lib - locker.lib crypto.lib common.lib scriptexecuter.lib diff --git a/projects/stargazer/corps_impl.cpp b/projects/stargazer/corps_impl.cpp index a366f466..4109bb28 100644 --- a/projects/stargazer/corps_impl.cpp +++ b/projects/stargazer/corps_impl.cpp @@ -43,7 +43,7 @@ Read(); //----------------------------------------------------------------------------- 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) @@ -81,7 +81,7 @@ return -1; //----------------------------------------------------------------------------- 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) @@ -125,7 +125,7 @@ return 0; //----------------------------------------------------------------------------- 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) @@ -161,7 +161,7 @@ return 0; //----------------------------------------------------------------------------- bool CORPORATIONS_IMPL::Read() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::vector corpsList; if (store->GetCorpsList(&corpsList) < 0) { @@ -188,7 +188,7 @@ bool CORPORATIONS_IMPL::Find(const std::string & name, CORP_CONF * corp) { assert(corp != NULL && "Pointer to corporation is not null"); -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (data.empty()) return false; @@ -205,7 +205,7 @@ return true; //----------------------------------------------------------------------------- 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"); @@ -222,7 +222,7 @@ return false; //----------------------------------------------------------------------------- int CORPORATIONS_IMPL::OpenSearch() const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); handle++; searchDescriptors[handle] = data.begin(); return handle; @@ -230,7 +230,7 @@ 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."); @@ -247,7 +247,7 @@ return 0; //----------------------------------------------------------------------------- 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)); diff --git a/projects/stargazer/eventloop.cpp b/projects/stargazer/eventloop.cpp index 6cc59c94..36a77e9e 100644 --- a/projects/stargazer/eventloop.cpp +++ b/projects/stargazer/eventloop.cpp @@ -63,7 +63,7 @@ printfd(__FILE__, "EVENT_LOOP::Runner - Before start\n"); while (_running) { { - STG_LOCKER lock(&_mutex, __FILE__, __LINE__); + STG_LOCKER lock(&_mutex); // Check for any actions... if (empty()) { @@ -101,7 +101,7 @@ EVENT_LOOP & EVENT_LOOP_SINGLETON::GetInstance() // Double-checking technique if (!_instance) { - STG_LOCKER lock(&singletonMutex, __FILE__, __LINE__); + STG_LOCKER lock(&singletonMutex); if (!_instance) { CreateInstance(); diff --git a/projects/stargazer/eventloop.h b/projects/stargazer/eventloop.h index 35de3675..0e798142 100644 --- a/projects/stargazer/eventloop.h +++ b/projects/stargazer/eventloop.h @@ -53,7 +53,7 @@ void EVENT_LOOP::Enqueue(ACTIVE_CLASS & ac, typename ACTOR::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 diff --git a/projects/stargazer/plugins/authorization/ao/Makefile b/projects/stargazer/plugins/authorization/ao/Makefile index 0e356aa1..cd9b7c05 100644 --- a/projects/stargazer/plugins/authorization/ao/Makefile +++ b/projects/stargazer/plugins/authorization/ao/Makefile @@ -10,7 +10,6 @@ SRCS = ./ao.cpp STGLIBS = scriptexecuter \ logger \ - locker \ common include ../../Makefile.in diff --git a/projects/stargazer/plugins/authorization/inetaccess/Makefile b/projects/stargazer/plugins/authorization/inetaccess/Makefile index 6f735ad8..f7eeabb3 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/Makefile +++ b/projects/stargazer/plugins/authorization/inetaccess/Makefile @@ -13,7 +13,6 @@ SRCS = ./inetaccess.cpp STGLIBS = common \ crypto \ logger \ - locker \ scriptexecuter include ../../Makefile.in diff --git a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp index 7894d491..03e30422 100644 --- a/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp +++ b/projects/stargazer/plugins/authorization/inetaccess/inetaccess.cpp @@ -684,7 +684,7 @@ return 0; //----------------------------------------------------------------------------- int AUTH_IA::Timeouter() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::map::iterator it; it = ip2user.begin(); @@ -771,7 +771,7 @@ int AUTH_IA::PacketProcessor(void * buff, size_t dataLen, uint32_t sip, uint16_t 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::iterator it(ip2user.find(sip)); if (it == ip2user.end()) @@ -958,7 +958,7 @@ if (!ip) std::map::iterator it; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); it = ip2user.find(ip); if (it == ip2user.end()) { @@ -1046,7 +1046,7 @@ printfd(__FILE__, "SendMessage userIP=%s\n", inet_ntostring(ip).c_str()); std::map::iterator it; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); it = ip2user.find(ip); if (it == ip2user.end()) { diff --git a/projects/stargazer/plugins/authorization/stress/Makefile b/projects/stargazer/plugins/authorization/stress/Makefile index 411acfaf..31283244 100644 --- a/projects/stargazer/plugins/authorization/stress/Makefile +++ b/projects/stargazer/plugins/authorization/stress/Makefile @@ -12,7 +12,6 @@ LIBS += $(LIB_THREAD) STGLIBS = common \ logger \ - locker \ scriptexecuter include ../../Makefile.in diff --git a/projects/stargazer/plugins/capture/divert_freebsd/Makefile b/projects/stargazer/plugins/capture/divert_freebsd/Makefile index 555ec8b1..076443bb 100644 --- a/projects/stargazer/plugins/capture/divert_freebsd/Makefile +++ b/projects/stargazer/plugins/capture/divert_freebsd/Makefile @@ -6,7 +6,7 @@ include ../../../../../Makefile.conf PROG = mod_cap_divert.so -SRCS = ./divert_cap.cpp +SRCS = ./divert_cap.cpp LIBS += $(LIB_THREAD) diff --git a/projects/stargazer/plugins/capture/ether_freebsd/Makefile b/projects/stargazer/plugins/capture/ether_freebsd/Makefile index aeb77636..2b859dbb 100644 --- a/projects/stargazer/plugins/capture/ether_freebsd/Makefile +++ b/projects/stargazer/plugins/capture/ether_freebsd/Makefile @@ -6,7 +6,7 @@ include ../../../../../Makefile.conf PROG = mod_cap_bpf.so -SRCS = ./ether_cap.cpp +SRCS = ./ether_cap.cpp LIBS += $(LIB_THREAD) diff --git a/projects/stargazer/plugins/configuration/rpcconfig/Makefile b/projects/stargazer/plugins/configuration/rpcconfig/Makefile index b2bdabf6..cbbe79c6 100644 --- a/projects/stargazer/plugins/configuration/rpcconfig/Makefile +++ b/projects/stargazer/plugins/configuration/rpcconfig/Makefile @@ -25,7 +25,6 @@ LIBS += -liconv endif STGLIBS = common \ - locker \ logger \ scriptexecuter diff --git a/projects/stargazer/plugins/configuration/sgconfig/Makefile b/projects/stargazer/plugins/configuration/sgconfig/Makefile index 1b59f5cf..f1bf357a 100644 --- a/projects/stargazer/plugins/configuration/sgconfig/Makefile +++ b/projects/stargazer/plugins/configuration/sgconfig/Makefile @@ -19,7 +19,6 @@ LIBS += -lexpat \ $(LIB_THREAD) STGLIBS = common \ - locker \ logger \ crypto \ scriptexecuter diff --git a/projects/stargazer/plugins/other/ping/Makefile b/projects/stargazer/plugins/other/ping/Makefile index 931c3f4a..4edc9529 100644 --- a/projects/stargazer/plugins/other/ping/Makefile +++ b/projects/stargazer/plugins/other/ping/Makefile @@ -12,7 +12,6 @@ SRCS = ./ping.cpp STGLIBS = pinger \ common \ - locker \ logger \ scriptexecuter diff --git a/projects/stargazer/plugins/other/ping/ping.cpp b/projects/stargazer/plugins/other/ping/ping.cpp index 7c4050ab..c65a5cba 100644 --- a/projects/stargazer/plugins/other/ping/ping.cpp +++ b/projects/stargazer/plugins/other/ping/ping.cpp @@ -124,7 +124,7 @@ return 0; //----------------------------------------------------------------------------- int PING::Stop() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (!isRunning) return 0; @@ -178,7 +178,7 @@ while (ping->nonstop) { std::list::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()) @@ -268,7 +268,7 @@ if (IPIter != ChgIPNotifierList.end()) //----------------------------------------------------------------------------- void PING::GetUsers() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); USER_PTR u; int h = users->OpenSearch(); @@ -297,7 +297,7 @@ users->CloseSearch(h); //----------------------------------------------------------------------------- void PING::AddUser(USER_PTR u) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); SetUserNotifiers(u); usersList.push_back(u); @@ -305,7 +305,7 @@ usersList.push_back(u); //----------------------------------------------------------------------------- void PING::DelUser(USER_PTR u) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); UnSetUserNotifiers(u); diff --git a/projects/stargazer/plugins/other/radius/Makefile b/projects/stargazer/plugins/other/radius/Makefile index 06f467ba..62a05183 100644 --- a/projects/stargazer/plugins/other/radius/Makefile +++ b/projects/stargazer/plugins/other/radius/Makefile @@ -13,7 +13,6 @@ SRCS = ./radius.cpp STGLIBS = common \ crypto \ logger \ - locker \ scriptexecuter include ../../Makefile.in diff --git a/projects/stargazer/plugins/other/rscript/Makefile b/projects/stargazer/plugins/other/rscript/Makefile index f9ba3ba1..50922cc1 100644 --- a/projects/stargazer/plugins/other/rscript/Makefile +++ b/projects/stargazer/plugins/other/rscript/Makefile @@ -13,7 +13,6 @@ SRCS = ./rscript.cpp \ STGLIBS = common \ crypto \ - locker \ logger \ scriptexecuter diff --git a/projects/stargazer/plugins/other/rscript/rscript.cpp b/projects/stargazer/plugins/other/rscript/rscript.cpp index e781a8cb..00114df4 100644 --- a/projects/stargazer/plugins/other/rscript/rscript.cpp +++ b/projects/stargazer/plugins/other/rscript/rscript.cpp @@ -313,7 +313,7 @@ if (nrMapParser.ReadFile(rsSettings.GetMapFileName())) } { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); printfd(__FILE__, "REMOTE_SCRIPT::Reload()\n"); @@ -353,7 +353,7 @@ return false; //----------------------------------------------------------------------------- void REMOTE_SCRIPT::PeriodicSend() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::map::iterator it(authorizedUsers.begin()); while (it != authorizedUsers.end()) @@ -510,7 +510,7 @@ return false; //----------------------------------------------------------------------------- std::vector 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)) @@ -545,13 +545,13 @@ void REMOTE_SCRIPT::AddRSU(USER_PTR user) 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::iterator it(authorizedUsers.begin()); while (it != authorizedUsers.end()) { diff --git a/projects/stargazer/plugins/other/smux/Makefile b/projects/stargazer/plugins/other/smux/Makefile index 1c875dcd..08569e59 100644 --- a/projects/stargazer/plugins/other/smux/Makefile +++ b/projects/stargazer/plugins/other/smux/Makefile @@ -14,7 +14,6 @@ SRCS = smux.cpp \ STGLIBS = common \ smux \ logger \ - locker \ scriptexecuter CFLAGS += -I ../../../../../stglibs/smux.lib/include/stg diff --git a/projects/stargazer/plugins/store/files/Makefile b/projects/stargazer/plugins/store/files/Makefile index 372a3cd4..c952d8a1 100644 --- a/projects/stargazer/plugins/store/files/Makefile +++ b/projects/stargazer/plugins/store/files/Makefile @@ -10,7 +10,6 @@ SRCS = ./file_store.cpp STGLIBS = conffiles \ common \ - locker \ logger \ crypto diff --git a/projects/stargazer/plugins/store/files/file_store.cpp b/projects/stargazer/plugins/store/files/file_store.cpp index bf5d389a..9d66e352 100644 --- a/projects/stargazer/plugins/store/files/file_store.cpp +++ b/projects/stargazer/plugins/store/files/file_store.cpp @@ -358,7 +358,7 @@ int FILES_STORE::ParseSettings() int ret = storeSettings.ParseSettings(settings); if (ret) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = storeSettings.GetStrError(); } return ret; @@ -370,12 +370,12 @@ std::vector files; 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); @@ -388,12 +388,12 @@ std::vector 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); @@ -406,12 +406,12 @@ std::vector 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); @@ -448,7 +448,7 @@ while ((entry = readdir(d))) { if (unlink(str.c_str())) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = "unlink failed. Message: '"; errorStr += strerror(errno); errorStr += "'"; @@ -473,7 +473,7 @@ closedir(d); if (rmdir(path)) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = "rmdir failed. Message: '"; errorStr += strerror(errno); errorStr += "'"; @@ -492,7 +492,7 @@ strprintf(&fileName, "%s%s", storeSettings.GetUsersDir().c_str(), login.c_str()) 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; @@ -501,7 +501,7 @@ if (mkdir(fileName.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) == 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; @@ -510,7 +510,7 @@ if (Touch(fileName)) 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; @@ -528,7 +528,7 @@ if (access(dirName.c_str(), F_OK) != 0) { 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; @@ -541,7 +541,7 @@ if (access(dirName.c_str(), F_OK) == 0) 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; @@ -580,7 +580,7 @@ int e = cf.Error(); 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; @@ -588,14 +588,14 @@ if (e) 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; @@ -603,14 +603,14 @@ if (conf->password.empty()) 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; @@ -625,7 +625,7 @@ try } 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; @@ -634,7 +634,7 @@ conf->ips = ips; 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; @@ -642,7 +642,7 @@ if (cf.ReadInt("alwaysOnline", &conf->alwaysOnline, 0) != 0) 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; @@ -650,7 +650,7 @@ if (cf.ReadInt("down", &conf->disabled, 0) != 0) 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; @@ -675,7 +675,7 @@ for (int i = 0; i < USERDATA_NUM; i++) 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; @@ -708,7 +708,7 @@ int e = cf.Error(); 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; @@ -722,7 +722,7 @@ for (int i = 0; i < DIR_NUM; i++) 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; @@ -732,7 +732,7 @@ for (int i = 0; i < DIR_NUM; i++) 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; @@ -742,7 +742,7 @@ for (int i = 0; i < DIR_NUM; i++) 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; @@ -750,7 +750,7 @@ if (cf.ReadDouble("Cash", &stat->cash, 0) != 0) 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; @@ -758,7 +758,7 @@ if (cf.ReadDouble("FreeMb", &stat->freeMb, 0) != 0) 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; @@ -766,7 +766,7 @@ if (cf.ReadTime("LastCashAddTime", &stat->lastCashAddTime, 0) != 0) 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; @@ -774,7 +774,7 @@ if (cf.ReadTime("PassiveTime", &stat->passiveTime, 0) != 0) 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; @@ -782,7 +782,7 @@ if (cf.ReadDouble("LastCashAdd", &stat->lastCashAdd, 0) != 0) 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; @@ -802,7 +802,7 @@ int e = cfstat.Error(); 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; @@ -813,7 +813,7 @@ e += chown(fileName.c_str(), storeSettings.GetConfUID(), storeSettings.GetConfGI 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)); } @@ -858,7 +858,7 @@ fileName = storeSettings.GetUsersDir() + "/" + login + "/stat"; 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; @@ -886,7 +886,7 @@ e += chown(fileName.c_str(), storeSettings.GetStatUID(), storeSettings.GetStatGI 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)); } @@ -911,7 +911,7 @@ if (f) } 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; @@ -922,7 +922,7 @@ e += chown(fileName.c_str(), storeSettings.GetLogUID(), storeSettings.GetLogGID( 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)); } @@ -947,7 +947,7 @@ if (f) } 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; @@ -958,7 +958,7 @@ e += chown(fileName.c_str(), storeSettings.GetLogUID(), storeSettings.GetLogGID( 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)); } @@ -1035,7 +1035,7 @@ CONFIGFILE s(stat1, true); 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; @@ -1050,7 +1050,7 @@ CONFIGFILE s2(stat2, true); 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; @@ -1088,7 +1088,7 @@ strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), login.c_ 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; @@ -1103,7 +1103,7 @@ std::string fileName; 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 += "'"; @@ -1125,7 +1125,7 @@ strprintf(&fileName, "%s/%s.adm", storeSettings.GetAdminsDir().c_str(), ac.login 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; @@ -1181,7 +1181,7 @@ std::string p; 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; @@ -1189,7 +1189,7 @@ if (cf.Error()) 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; @@ -1223,7 +1223,7 @@ if (cf.ReadUShortInt("ChgConf", &a, 0) == 0) 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; @@ -1233,7 +1233,7 @@ if (cf.ReadUShortInt("ChgPassword", &a, 0) == 0) 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; @@ -1243,7 +1243,7 @@ if (cf.ReadUShortInt("ChgStat", &a, 0) == 0) 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; @@ -1253,7 +1253,7 @@ if (cf.ReadUShortInt("ChgCash", &a, 0) == 0) 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; @@ -1263,7 +1263,7 @@ if (cf.ReadUShortInt("UsrAddDel", &a, 0) == 0) 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; @@ -1273,7 +1273,7 @@ if (cf.ReadUShortInt("ChgAdmin", &a, 0) == 0) 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; @@ -1283,7 +1283,7 @@ if (cf.ReadUShortInt("ChgTariff", &a, 0) == 0) 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; @@ -1308,7 +1308,7 @@ std::string fileName; 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; @@ -1322,7 +1322,7 @@ std::string fileName; 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 += "'"; @@ -1340,7 +1340,7 @@ td->tariffConf.name = tariffName; 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; @@ -1352,7 +1352,7 @@ for (int i = 0; idirPrice[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; @@ -1377,7 +1377,7 @@ for (int i = 0; idirPrice[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; @@ -1387,7 +1387,7 @@ for (int i = 0; idirPrice[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; @@ -1397,7 +1397,7 @@ for (int i = 0; idirPrice[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; @@ -1407,7 +1407,7 @@ for (int i = 0; idirPrice[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; @@ -1416,7 +1416,7 @@ for (int i = 0; idirPrice[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; @@ -1425,7 +1425,7 @@ for (int i = 0; idirPrice[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; @@ -1434,7 +1434,7 @@ for (int i = 0; itariffConf.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; @@ -1442,7 +1442,7 @@ if (conf.ReadDouble("Fee", &td->tariffConf.fee, 0) < 0) 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; @@ -1450,7 +1450,7 @@ if (conf.ReadDouble("Free", &td->tariffConf.free, 0) < 0) 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; @@ -1458,7 +1458,7 @@ if (conf.ReadDouble("PassiveCost", &td->tariffConf.passiveCost, 0) < 0) 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; @@ -1477,7 +1477,7 @@ else 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; @@ -1501,7 +1501,7 @@ std::string fileName = storeSettings.GetTariffsDir() + "/" + tariffName + ".tf"; 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; @@ -1586,7 +1586,7 @@ if (access(dn, F_OK) != 0) { 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; @@ -1598,7 +1598,7 @@ e += chmod(dn, storeSettings.GetStatModeDir()); 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)); } @@ -1619,7 +1619,7 @@ if (access(dn, F_OK) != 0) { 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; @@ -1631,7 +1631,7 @@ e += chmod(dn, storeSettings.GetStatModeDir()); 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)); } @@ -1645,7 +1645,7 @@ if (access(dn, F_OK) != 0) { 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; @@ -1657,7 +1657,7 @@ e += chmod(dn, storeSettings.GetStatModeDir()); 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)); } @@ -1667,7 +1667,7 @@ statFile = fopen (fn, "at"); 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; @@ -1694,7 +1694,7 @@ s2 = lt2->tm_sec; 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); @@ -1718,7 +1718,7 @@ while (stIter != statTree.end()) 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 += "'"; @@ -1734,7 +1734,7 @@ while (stIter != statTree.end()) 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 += "'"; @@ -1754,7 +1754,7 @@ e += chmod(fn, storeSettings.GetStatMode()); 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)); } @@ -1772,7 +1772,7 @@ if (access(dn.c_str(), F_OK) != 0) { 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."; @@ -1790,7 +1790,7 @@ strprintf(&fn, "%s/%lld", dn.c_str(), msg->header.id); if (Touch(fn)) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = "File \'"; errorStr += fn; errorStr += "\' cannot be writen."; @@ -1812,7 +1812,7 @@ if (access(fileName.c_str(), F_OK) != 0) { 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."; @@ -1825,7 +1825,7 @@ Touch(fileName + ".new"); 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; @@ -1842,7 +1842,7 @@ res &= (fprintf(msgFile, "%s", msg.text.c_str()) >= 0); 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); @@ -1855,7 +1855,7 @@ chmod((fileName + ".new").c_str(), storeSettings.GetConfMode()); 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; @@ -1900,7 +1900,7 @@ for (unsigned i = 0; i < messages.size(); i++) { 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; @@ -1918,7 +1918,7 @@ for (unsigned i = 0; i < messages.size(); i++) { 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; @@ -1940,7 +1940,7 @@ FILE * msgFile; 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."; @@ -1961,7 +1961,7 @@ memset(p, 0, sizeof(p)); 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."; @@ -1979,7 +1979,7 @@ for (int pos = 0; pos < 6; pos++) if (feof(msgFile)) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = "Cannot read file \'"; errorStr += fileName; errorStr += "\'. Missing data."; @@ -1991,7 +1991,7 @@ for (int pos = 0; pos < 6; pos++) if (str2x(p, *(d[pos]))) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); errorStr = "Cannot read file \'"; errorStr += fileName; errorStr += "\'. Incorrect value. \'"; diff --git a/projects/stargazer/plugins/store/firebird/Makefile b/projects/stargazer/plugins/store/firebird/Makefile index 0e669751..a6fb9ccd 100644 --- a/projects/stargazer/plugins/store/firebird/Makefile +++ b/projects/stargazer/plugins/store/firebird/Makefile @@ -19,7 +19,6 @@ SRCS = ./firebird_store.cpp \ STGLIBS = ibpp \ common \ - locker \ logger \ crypto diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp index 25a2bf51..ae0b9e6d 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_admins.cpp @@ -40,7 +40,7 @@ using namespace std; //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetAdminsList(vector * 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); @@ -72,7 +72,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -130,7 +130,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -193,7 +193,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -231,7 +231,7 @@ return 0; //----------------------------------------------------------------------------- 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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_corporations.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_corporations.cpp index 6b457de0..6c483880 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_corporations.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_corporations.cpp @@ -32,7 +32,7 @@ //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetCorpsList(std::vector * 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); @@ -64,7 +64,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -92,7 +92,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -130,7 +130,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -157,7 +157,7 @@ return 0; //----------------------------------------------------------------------------- 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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_messages.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_messages.cpp index e14ad356..5f9e62bd 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_messages.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_messages.cpp @@ -33,7 +33,7 @@ //----------------------------------------------------------------------------- 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); @@ -70,7 +70,7 @@ return 0; 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); @@ -108,7 +108,7 @@ int FIREBIRD_STORE::GetMessage(uint64_t id, 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); @@ -154,7 +154,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -182,7 +182,7 @@ return 0; int FIREBIRD_STORE::GetMessageHdrs(std::vector * 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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_services.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_services.cpp index 6f6bee30..93b7c745 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_services.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_services.cpp @@ -33,7 +33,7 @@ //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetServicesList(std::vector * 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); @@ -65,7 +65,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -100,7 +100,7 @@ return 0; 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); @@ -142,7 +142,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -170,7 +170,7 @@ return 0; //----------------------------------------------------------------------------- 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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp index 8fd23569..f757d055 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_tariffs.cpp @@ -34,7 +34,7 @@ //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetTariffsList(std::vector * 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); @@ -66,7 +66,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -94,7 +94,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -122,7 +122,7 @@ return 0; 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); @@ -249,7 +249,7 @@ return 0; 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); diff --git a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp index 13162207..8c214fbf 100644 --- a/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp +++ b/projects/stargazer/plugins/store/firebird/firebird_store_users.cpp @@ -33,7 +33,7 @@ //----------------------------------------------------------------------------- int FIREBIRD_STORE::GetUsersList(std::vector * 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); @@ -65,7 +65,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -93,7 +93,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -121,7 +121,7 @@ return 0; 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); } @@ -226,7 +226,7 @@ return 0; 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); @@ -354,7 +354,7 @@ return 0; 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); @@ -441,7 +441,7 @@ return 0; 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); @@ -567,7 +567,7 @@ int FIREBIRD_STORE::WriteUserChgLog(const std::string & login, 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); @@ -627,7 +627,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -664,7 +664,7 @@ int FIREBIRD_STORE::WriteUserDisconnect(const std::string & login, 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); @@ -712,7 +712,7 @@ int FIREBIRD_STORE::WriteDetailedStat(const std::map & s 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); @@ -762,7 +762,7 @@ return 0; //----------------------------------------------------------------------------- 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); diff --git a/projects/stargazer/plugins/store/postgresql/Makefile b/projects/stargazer/plugins/store/postgresql/Makefile index 0bd8f629..ef090f17 100644 --- a/projects/stargazer/plugins/store/postgresql/Makefile +++ b/projects/stargazer/plugins/store/postgresql/Makefile @@ -17,7 +17,6 @@ SRCS = ./postgresql_store.cpp \ STGLIBS = common \ crypto \ - locker \ logger PG_CFLAGS = $(shell pg_config --includedir) diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_admins.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_admins.cpp index 1e9db12d..63cf3d5c 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_admins.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_admins.cpp @@ -42,7 +42,7 @@ //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetAdminsList(std::vector * adminsList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -98,7 +98,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::SaveAdmin(const ADMIN_CONF & ac) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -197,7 +197,7 @@ return 0; //----------------------------------------------------------------------------- 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) { @@ -318,7 +318,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddAdmin(const std::string & login) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -388,7 +388,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelAdmin(const std::string & login) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp index 1d33d5b0..84fab02b 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_corporations.cpp @@ -38,7 +38,7 @@ //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetCorpsList(std::vector * corpsList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -94,7 +94,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::SaveCorp(const CORP_CONF & cc) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -160,7 +160,7 @@ return 0; //----------------------------------------------------------------------------- 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) { @@ -243,7 +243,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddCorp(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -310,7 +310,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelCorp(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp index 5a55504d..27401e26 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_messages.cpp @@ -40,7 +40,7 @@ //----------------------------------------------------------------------------- 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) { @@ -143,7 +143,7 @@ return 0; 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) { @@ -229,7 +229,7 @@ int POSTGRESQL_STORE::GetMessage(uint64_t id, STG_MSG * msg, const std::string &) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -307,7 +307,7 @@ return 0; //----------------------------------------------------------------------------- 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) { @@ -359,7 +359,7 @@ return 0; int POSTGRESQL_STORE::GetMessageHdrs(std::vector * hdrsList, const std::string & login) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_services.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_services.cpp index 825f7982..70b9c64c 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_services.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_services.cpp @@ -39,7 +39,7 @@ //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetServicesList(std::vector * servicesList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -95,7 +95,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::SaveService(const SERVICE_CONF & sc) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -175,7 +175,7 @@ return 0; 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) { @@ -262,7 +262,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddService(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -329,7 +329,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelService(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp index d4fdd390..dabc06db 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_tariffs.cpp @@ -39,7 +39,7 @@ //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetTariffsList(std::vector * tariffsList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -95,7 +95,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddTariff(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -158,7 +158,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelTariff(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -222,7 +222,7 @@ return 0; 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) { @@ -403,7 +403,7 @@ return 0; 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) { diff --git a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp index b990300c..db2717ac 100644 --- a/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp +++ b/projects/stargazer/plugins/store/postgresql/postgresql_store_users.cpp @@ -41,7 +41,7 @@ //----------------------------------------------------------------------------- int POSTGRESQL_STORE::GetUsersList(std::vector * usersList) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -97,7 +97,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::AddUser(const std::string & name) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -161,7 +161,7 @@ return 0; //----------------------------------------------------------------------------- int POSTGRESQL_STORE::DelUser(const std::string & login) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -225,7 +225,7 @@ return 0; 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); } @@ -336,7 +336,7 @@ return 0; 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) { @@ -607,7 +607,7 @@ return 0; 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) { @@ -747,7 +747,7 @@ return 0; 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) { @@ -994,7 +994,7 @@ int POSTGRESQL_STORE::WriteUserChgLog(const std::string & login, const std::string & newValue, const std::string & message = "") const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -1111,7 +1111,7 @@ return 0; //----------------------------------------------------------------------------- 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) { @@ -1197,7 +1197,7 @@ int POSTGRESQL_STORE::WriteUserDisconnect(const std::string & login, double freeMb, const std::string & reason) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -1356,7 +1356,7 @@ int POSTGRESQL_STORE::WriteDetailedStat(const std::map & time_t lastStat, const std::string & login) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (PQstatus(connection) != CONNECTION_OK) { @@ -1435,7 +1435,7 @@ return 0; //----------------------------------------------------------------------------- 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); } diff --git a/projects/stargazer/services_impl.cpp b/projects/stargazer/services_impl.cpp index 832bf7e9..aebb98fb 100644 --- a/projects/stargazer/services_impl.cpp +++ b/projects/stargazer/services_impl.cpp @@ -43,7 +43,7 @@ Read(); //----------------------------------------------------------------------------- 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) @@ -81,7 +81,7 @@ return -1; //----------------------------------------------------------------------------- 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) @@ -125,7 +125,7 @@ return 0; //----------------------------------------------------------------------------- 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) @@ -161,7 +161,7 @@ return 0; //----------------------------------------------------------------------------- bool SERVICES_IMPL::Read() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::vector servicesList; if (store->GetServicesList(&servicesList) < 0) { @@ -188,7 +188,7 @@ bool SERVICES_IMPL::Find(const std::string & name, SERVICE_CONF * service) { assert(service != NULL && "Pointer to service is not null"); -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (data.empty()) return false; @@ -205,7 +205,7 @@ return true; //----------------------------------------------------------------------------- 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"); @@ -222,7 +222,7 @@ return false; //----------------------------------------------------------------------------- int SERVICES_IMPL::OpenSearch() const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); handle++; searchDescriptors[handle] = data.begin(); return handle; @@ -230,7 +230,7 @@ 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."); @@ -247,7 +247,7 @@ return 0; //----------------------------------------------------------------------------- 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)); diff --git a/projects/stargazer/tariffs_impl.cpp b/projects/stargazer/tariffs_impl.cpp index dbd3d2e3..aee486d7 100644 --- a/projects/stargazer/tariffs_impl.cpp +++ b/projects/stargazer/tariffs_impl.cpp @@ -63,7 +63,7 @@ pthread_mutex_destroy(&mutex); //----------------------------------------------------------------------------- int TARIFFS_IMPL::ReadTariffs() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); vector tariffsList; if (store->GetTariffsList(&tariffsList)) @@ -91,7 +91,7 @@ return 0; //----------------------------------------------------------------------------- size_t TARIFFS_IMPL::Count() const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); return tariffs.size(); } //----------------------------------------------------------------------------- @@ -100,7 +100,7 @@ const TARIFF * TARIFFS_IMPL::FindByName(const string & name) const if (name == NO_TARIFF_NAME) return &noTariff; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); list::const_iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -123,7 +123,7 @@ if (!priv->tariffChg) return -1; } -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(td.tariffConf.name)); @@ -166,7 +166,7 @@ if (!priv->tariffChg) TARIFF_DATA td; { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -217,7 +217,7 @@ if (!priv->tariffChg) } { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); list::iterator ti; ti = find(tariffs.begin(), tariffs.end(), TARIFF_IMPL(name)); @@ -256,7 +256,7 @@ return 0; void TARIFFS_IMPL::GetTariffsData(std::list * 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) @@ -267,25 +267,25 @@ for (; it != tariffs.end(); ++it) //----------------------------------------------------------------------------- void TARIFFS_IMPL::AddNotifierAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.insert(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::DelNotifierAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.erase(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::AddNotifierDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.insert(n); } //----------------------------------------------------------------------------- void TARIFFS_IMPL::DelNotifierDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.erase(n); } //----------------------------------------------------------------------------- diff --git a/projects/stargazer/traffcounter_impl.cpp b/projects/stargazer/traffcounter_impl.cpp index 985de593..5223c5c4 100644 --- a/projects/stargazer/traffcounter_impl.cpp +++ b/projects/stargazer/traffcounter_impl.cpp @@ -97,7 +97,7 @@ pthread_mutex_destroy(&mutex); //----------------------------------------------------------------------------- int TRAFFCOUNTER_IMPL::Start() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (!stopped) return 0; @@ -212,7 +212,7 @@ if (monitoring && (touchTimeP + MONITOR_TIME_DELAY_SEC <= stgTime)) 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. @@ -290,7 +290,7 @@ if (ed.userUPresent || //----------------------------------------------------------------------------- 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(); @@ -377,7 +377,7 @@ printfd(__FILE__, "AddUser: %s\n", user->GetLogin().c_str()); uint32_t uip = user->GetCurrIP(); std::pair 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); @@ -414,7 +414,7 @@ void TRAFFCOUNTER_IMPL::DelUser(uint32_t uip) printfd(__FILE__, "DelUser: %s \n", inet_ntostring(uip).c_str()); std::pair pi; -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); pi = ip2packets.equal_range(uip); while (pi.first != pi.second) @@ -717,7 +717,7 @@ return false; //----------------------------------------------------------------------------- int TRAFFCOUNTER_IMPL::Reload() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (ReadRules(true)) { diff --git a/projects/stargazer/user_impl.cpp b/projects/stargazer/user_impl.cpp index 47f35228..22afa7f8 100644 --- a/projects/stargazer/user_impl.cpp +++ b/projects/stargazer/user_impl.cpp @@ -319,7 +319,7 @@ pthread_mutex_destroy(&mutex); //----------------------------------------------------------------------------- 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(); @@ -327,7 +327,7 @@ 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)) @@ -375,7 +375,7 @@ return 0; //----------------------------------------------------------------------------- int USER_IMPL::ReadStat() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); USER_STAT stat; if (store->RestoreUserStat(&stat, login)) @@ -394,7 +394,7 @@ return 0; //----------------------------------------------------------------------------- int USER_IMPL::WriteConf() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); USER_CONF conf(property.GetConf()); printfd(__FILE__, "USER::WriteConf()\n"); @@ -413,7 +413,7 @@ return 0; //----------------------------------------------------------------------------- int USER_IMPL::WriteStat() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); USER_STAT stat(property.GetStat()); if (store->SaveUserStat(stat, login)) @@ -432,7 +432,7 @@ return 0; //----------------------------------------------------------------------------- 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); @@ -452,7 +452,7 @@ return 0; //----------------------------------------------------------------------------- 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. @@ -527,7 +527,7 @@ return 0; //----------------------------------------------------------------------------- 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 */ @@ -546,7 +546,7 @@ if (authorizedBy.empty()) //----------------------------------------------------------------------------- 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(); } @@ -564,7 +564,7 @@ void USER_IMPL::Connect(bool fakeConnect) * Connect user to Internet. This function is differ from Authorize() !!! */ -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (!fakeConnect) { @@ -623,7 +623,7 @@ void USER_IMPL::Disconnect(bool fakeDisconnect, const std::string & reason) * Disconnect user from Internet. This function is differ from UnAuthorize() !!! */ -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (!lastIPForDisconnect) { @@ -695,7 +695,7 @@ sessionDownload = zeroSesssion; 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; @@ -731,7 +731,7 @@ std::cout << "============================================================" << s //----------------------------------------------------------------------------- void USER_IMPL::Run() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (stgTime > static_cast(lastWriteStat + settings->GetStatWritePeriod())) { @@ -792,7 +792,7 @@ else //----------------------------------------------------------------------------- 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; @@ -802,7 +802,7 @@ else //----------------------------------------------------------------------------- bool USER_IMPL::IsInetable() { -//STG_LOCKER lock(&mutex, __FILE__, __LINE__); +//STG_LOCKER lock(&mutex); if (disabled || passive) return false; @@ -823,7 +823,7 @@ return (cash - tariff->GetFee() >= -credit); //----------------------------------------------------------------------------- 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++) @@ -837,7 +837,7 @@ void USER_IMPL::AddTraffStatU(int dir, uint32_t ip, uint16_t port, uint32_t len) 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; @@ -929,7 +929,7 @@ void USER_IMPL::AddTraffStatD(int dir, uint32_t ip, uint16_t port, uint32_t len) 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; @@ -1016,55 +1016,55 @@ else //----------------------------------------------------------------------------- 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"; @@ -1086,7 +1086,7 @@ else //----------------------------------------------------------------------------- void USER_IMPL::OnDelete() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::string scriptOnDel = settings->GetScriptsDir() + "/OnUserDel"; @@ -1127,7 +1127,7 @@ if (!traffStatSaved.second.empty()) TRAFF_STAT ts; { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); ts.swap(traffStat); } @@ -1143,7 +1143,7 @@ if (ts.size() && !disabledDetailStat) 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; } @@ -1156,7 +1156,7 @@ return 0; //----------------------------------------------------------------------------- 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}; @@ -1183,7 +1183,7 @@ return static_cast(dt) / secMonth; //----------------------------------------------------------------------------- void USER_IMPL::SetPassiveTimeAsNewUser() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); time_t t = stgTime; struct tm tm; @@ -1197,7 +1197,7 @@ passiveTime = static_cast(pt * 24 * 3600 * daysCurrMon); //----------------------------------------------------------------------------- void USER_IMPL::MidnightResetSessionStat() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (connected) { @@ -1208,7 +1208,7 @@ if (connected) //----------------------------------------------------------------------------- void USER_IMPL::ProcessNewMonth() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); // Reset traff if (connected) { @@ -1248,7 +1248,7 @@ if (nextTariff.ConstData() != "") //----------------------------------------------------------------------------- void USER_IMPL::ProcessDayFeeSpread() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (passive.ConstData() || tariff == NULL) return; @@ -1285,7 +1285,7 @@ ResetPassiveTime(); //----------------------------------------------------------------------------- void USER_IMPL::ProcessDayFee() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (tariff == NULL) return; @@ -1356,7 +1356,7 @@ switch (settings->GetFeeChargeType()) //----------------------------------------------------------------------------- void USER_IMPL::ProcessDailyFee() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (passive.ConstData() || tariff == NULL) return; @@ -1395,7 +1395,7 @@ if (tariff != NULL) //----------------------------------------------------------------------------- int USER_IMPL::AddMessage(STG_MSG * msg) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); if (SendMessage(*msg)) { diff --git a/projects/stargazer/users_impl.cpp b/projects/stargazer/users_impl.cpp index f4b4dea0..d66456af 100644 --- a/projects/stargazer/users_impl.cpp +++ b/projects/stargazer/users_impl.cpp @@ -108,7 +108,7 @@ return 0; //----------------------------------------------------------------------------- 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; @@ -118,7 +118,7 @@ return 0; //----------------------------------------------------------------------------- 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; @@ -128,7 +128,7 @@ return 0; //----------------------------------------------------------------------------- bool USERS_IMPL::TariffInUse(const std::string & tariffName) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::list::const_iterator iter; iter = users.begin(); while (iter != users.end()) @@ -142,7 +142,7 @@ return false; //----------------------------------------------------------------------------- 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) @@ -233,7 +233,7 @@ if (!priv->userAddDel) { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); if (FindByNameNonLock(login, &u)) { @@ -265,7 +265,7 @@ if (!priv->userAddDel) } { - STG_LOCKER lock(&mutex, __FILE__, __LINE__); + STG_LOCKER lock(&mutex); u->OnDelete(); @@ -286,7 +286,7 @@ bool USERS_IMPL::Authorize(const std::string & login, uint32_t ip, 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()); @@ -319,7 +319,7 @@ bool USERS_IMPL::Unauthorize(const std::string & login, 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()); @@ -606,7 +606,7 @@ return 0; //----------------------------------------------------------------------------- void USERS_IMPL::RealDelUser() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); printfd(__FILE__, "RealDelUser() users to del: %d\n", usersToDelete.size()); @@ -641,7 +641,7 @@ uint32_t ip = user->GetCurrIP(); if (!ip) return; // User has disconnected -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); const std::map::iterator it( ipIndex.lower_bound(ip) @@ -657,7 +657,7 @@ void USERS_IMPL::DelFromIPIdx(uint32_t 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::iterator it( ipIndex.find(ip) @@ -680,7 +680,7 @@ return true; //----------------------------------------------------------------------------- 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)) @@ -694,7 +694,7 @@ return -1; //----------------------------------------------------------------------------- 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)) @@ -708,7 +708,7 @@ return -1; //----------------------------------------------------------------------------- bool USERS_IMPL::IsIPInIndex(uint32_t ip) const { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::map::const_iterator it(ipIndex.find(ip)); @@ -717,7 +717,7 @@ return it != ipIndex.end(); //----------------------------------------------------------------------------- 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::const_iterator iter; iter = users.begin(); while (iter != users.end()) @@ -737,55 +737,55 @@ return false; //----------------------------------------------------------------------------- void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.insert(n); } //----------------------------------------------------------------------------- void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiers.erase(n); } //----------------------------------------------------------------------------- void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.insert(n); } //----------------------------------------------------------------------------- void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiers.erase(n); } //----------------------------------------------------------------------------- void USERS_IMPL::AddNotifierUserAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiersImpl.insert(n); } //----------------------------------------------------------------------------- void USERS_IMPL::DelNotifierUserAdd(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onAddNotifiersImpl.erase(n); } //----------------------------------------------------------------------------- void USERS_IMPL::AddNotifierUserDel(NOTIFIER_BASE * n) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); onDelNotifiersImpl.insert(n); } //----------------------------------------------------------------------------- void USERS_IMPL::DelNotifierUserDel(NOTIFIER_BASE * 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; @@ -802,7 +802,7 @@ int USERS_IMPL::SearchNext(int h, USER_PTR * user) //----------------------------------------------------------------------------- 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()) { @@ -831,7 +831,7 @@ return 0; //----------------------------------------------------------------------------- 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)); @@ -844,13 +844,13 @@ return -1; //----------------------------------------------------------------------------- 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()); } //----------------------------------------------------------------------------- diff --git a/stglibs/locker.lib/Makefile b/stglibs/locker.lib/Makefile deleted file mode 100644 index 73452637..00000000 --- a/stglibs/locker.lib/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# $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 diff --git a/stglibs/locker.lib/include/stg/locker.h b/stglibs/locker.lib/include/stg/locker.h deleted file mode 100644 index 51ceb738..00000000 --- a/stglibs/locker.lib/include/stg/locker.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 - */ - -/* - $Revision: 1.5 $ - $Date: 2010/03/04 11:57:11 $ - $Author: faust $ -*/ - - -#ifndef STG_LOCKER_H -#define STG_LOCKER_H - -#include - -#ifdef DEBUG_LOCKER - -#include -#include -#include - -#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 diff --git a/stglibs/locker.lib/locker.cpp b/stglibs/locker.lib/locker.cpp deleted file mode 100644 index 94ef026a..00000000 --- a/stglibs/locker.lib/locker.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 - */ - -/* - $Revision: 1.2 $ - $Date: 2007/11/30 08:57:49 $ - $Author: nobunaga $ -*/ - -#ifdef DEBUG_LOCKER - -#include - -#include "stg/locker.h" - -long long STG_LOCKER::id = 0; -pthread_mutex_t STG_LOCKER::lockerMutex = PTHREAD_MUTEX_INITIALIZER; - -#endif - diff --git a/stglibs/pinger.lib/pinger.cpp b/stglibs/pinger.lib/pinger.cpp index edc8c174..1689e294 100644 --- a/stglibs/pinger.lib/pinger.cpp +++ b/stglibs/pinger.lib/pinger.cpp @@ -123,19 +123,19 @@ return 0; //----------------------------------------------------------------------------- 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::iterator iter; iter = ipToAdd.begin(); @@ -149,7 +149,7 @@ ipToAdd.erase(ipToAdd.begin(), ipToAdd.end()); //----------------------------------------------------------------------------- void STG_PINGER::RealDelIP() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::list::iterator iter; std::multimap::iterator treeIter; @@ -167,7 +167,7 @@ ipToDel.erase(ipToDel.begin(), ipToDel.end()); //----------------------------------------------------------------------------- void STG_PINGER::PrintAllIP() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +STG_LOCKER lock(&mutex); std::multimap::iterator iter; iter = pingIP.begin(); while (iter != pingIP.end()) @@ -184,7 +184,7 @@ 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::const_iterator treeIter; treeIter = pingIP.find(ip); diff --git a/stglibs/smux.lib/IpAddress.c b/stglibs/smux.lib/IpAddress.c index 8dbc66b7..0b073d2d 100644 --- a/stglibs/smux.lib/IpAddress.c +++ b/stglibs/smux.lib/IpAddress.c @@ -24,7 +24,7 @@ IpAddress_constraint(asn_TYPE_descriptor_t *td, const void *sptr, size = st->size; - if((size == 4)) { + if(size == 4) { /* Constraint check succeeded */ return 0; } else {