From c03710e5962e640d8a8e23cd9144e753ff282a50 Mon Sep 17 00:00:00 2001 From: Maxim Mamontov Date: Wed, 5 Jan 2011 17:25:43 +0200 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B8=20=D1=80=D0=BE=D0=B1=D0=BE?= =?utf8?q?=D1=82=D1=96=20=D0=B7=20=D0=BF=D0=BE=D0=B2=D1=96=D0=B4=D0=BE?= =?utf8?q?=D0=BC=D0=BB=D0=B5=D0=BD=D0=BD=D1=8F=D0=BC=D0=B8=20=D0=BF=D1=80?= =?utf8?q?=D0=B8=D0=B1=D1=80=D0=B0=D0=BD=D0=BE=20=D0=B7=D0=B0=D0=B9=D0=B2?= =?utf8?q?=D1=96=20=D0=B1=D0=BB=D0=BE=D0=BA=D1=83=D0=B2=D0=B0=D0=BD=D0=BD?= =?utf8?q?=D1=8F=20=D1=96=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B2=D1=96=D1=80?= =?utf8?q?=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- projects/stargazer/user.cpp | 46 +++++++++++++++---------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/projects/stargazer/user.cpp b/projects/stargazer/user.cpp index 50046fa5..b68c632a 100644 --- a/projects/stargazer/user.cpp +++ b/projects/stargazer/user.cpp @@ -1153,7 +1153,19 @@ int USER::AddMessage(STG_MSG * msg) { STG_LOCKER lock(&mutex, __FILE__, __LINE__); -if (SendMessage(*msg) == 0) +if (SendMessage(*msg)) + { + if (store->AddMessage(msg, login)) + { + errorStr = store->GetStrError(); + STG_LOGGER & WriteServLog = GetStgLogger(); + WriteServLog("Error adding message %s", errorStr.c_str()); + WriteServLog("%s", store->GetStrError().c_str()); + return -1; + } + messages.push_back(*msg); + } +else { if (msg->header.repeat > 0) { @@ -1175,46 +1187,26 @@ if (SendMessage(*msg) == 0) messages.push_back(*msg); } } -else - { - if (store->AddMessage(msg, login)) - { - errorStr = store->GetStrError(); - STG_LOGGER & WriteServLog = GetStgLogger(); - WriteServLog("Error adding message %s", errorStr.c_str()); - WriteServLog("%s", store->GetStrError().c_str()); - return -1; - } - messages.push_back(*msg); - } return 0; } //----------------------------------------------------------------------------- int USER::SendMessage(const STG_MSG & msg) { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); - -if (authorizedBy.empty()) - { - return -1; - } - +// No lock `cause we are already locked from caller int ret = -1; -set::iterator it; - -it = authorizedBy.begin(); +set::iterator it(authorizedBy.begin()); while (it != authorizedBy.end()) { - if ((*it)->SendMessage(msg, currIP) == 0) + if (!(*it++)->SendMessage(msg, currIP)) ret = 0; - ++it; } return ret; } //----------------------------------------------------------------------------- int USER::ScanMessage() { -STG_LOCKER lock(&mutex, __FILE__, __LINE__); +// No lock `cause we are already locked from caller +// We need not check for the authorizedBy `cause it has already checked by caller /*vector hdrsList; @@ -1268,7 +1260,7 @@ while (it != messages.end()) { if (SendMessage(*it)) { - break; + return -1; } it->header.repeat--; if (it->header.repeat < 0) -- 2.44.2