git.stg.codes
/
stg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add compiler existance checking
[stg.git]
/
projects
/
stargazer
/
plugins
/
store
/
mysql
/
mysql_store.cpp
diff --git
a/projects/stargazer/plugins/store/mysql/mysql_store.cpp
b/projects/stargazer/plugins/store/mysql/mysql_store.cpp
index 102be151dd27e736bb2dca8ceb0d690e81cb6abe..e9f529c6522fcd62020231ffacde835c09f682b4 100644
(file)
--- a/
projects/stargazer/plugins/store/mysql/mysql_store.cpp
+++ b/
projects/stargazer/plugins/store/mysql/mysql_store.cpp
@@
-118,7
+118,7
@@
public:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
-
BASE_
STORE * GetStore()
+STORE * GetStore()
{
return msc.GetStore();
}
{
return msc.GetStore();
}
@@
-711,6
+711,13
@@
if (!(res=mysql_store_result(sock)))
return -1;
}
return -1;
}
+if (mysql_num_rows(res) != 1)
+{
+ errorStr = "User not found";
+ mysql_close(sock);
+ return -1;
+}
+
row = mysql_fetch_row(res);
string param;
row = mysql_fetch_row(res);
string param;
@@
-797,7
+804,7
@@
try
{
i = StrToIPS(ipStr);
}
{
i = StrToIPS(ipStr);
}
-catch (
string
s)
+catch (
const string &
s)
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' data not read. Parameter IP address. " + s;
@@
-855,30
+862,29
@@
row = mysql_fetch_row(res);
unsigned int startPos=0;
char s[22];
unsigned int startPos=0;
char s[22];
-uint64_t traffU[DIR_NUM];
-uint64_t traffD[DIR_NUM];
for (int i = 0; i < DIR_NUM; i++)
{
for (int i = 0; i < DIR_NUM; i++)
{
+ uint64_t traff;
sprintf(s, "D%d", i);
sprintf(s, "D%d", i);
- if (GetULongLongInt(row[startPos+i*2],
&traffD[i]
, 0) != 0)
+ if (GetULongLongInt(row[startPos+i*2],
&traff
, 0) != 0)
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' stat not read. Parameter " + string(s);
mysql_close(sock);
return -1;
}
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' stat not read. Parameter " + string(s);
mysql_close(sock);
return -1;
}
- stat->down
= traffD
;
+ stat->down
[i] = traff
;
sprintf(s, "U%d", i);
sprintf(s, "U%d", i);
- if (GetULongLongInt(row[startPos+i*2+1], &traff
U[i]
, 0) != 0)
+ if (GetULongLongInt(row[startPos+i*2+1], &traff, 0) != 0)
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' stat not read. Parameter " + string(s);
mysql_close(sock);
return -1;
}
{
mysql_free_result(res);
errorStr = "User \'" + login + "\' stat not read. Parameter " + string(s);
mysql_close(sock);
return -1;
}
- stat->up
= traffU
;
+ stat->up
[i] = traff
;
}//for
startPos += (2*DIR_NUM);
}//for
startPos += (2*DIR_NUM);
@@
-1690,7
+1696,7
@@
if(MysqlSetQuery(res.c_str()))
return 0;
}
//-----------------------------------------------------------------------------
return 0;
}
//-----------------------------------------------------------------------------
-int MYSQL_STORE::WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE>
*
statTree,
+int MYSQL_STORE::WriteDetailedStat(const map<IP_DIR_PAIR, STAT_NODE>
&
statTree,
time_t lastStat,
const string & login) const
{
time_t lastStat,
const string & login) const
{
@@
-1775,11
+1781,10
@@
strprintf(&res,"INSERT INTO detailstat_%02d_%4d SET login='%s',"\
endTime.c_str()
);
endTime.c_str()
);
-int retRes;
map<IP_DIR_PAIR, STAT_NODE>::const_iterator stIter;
map<IP_DIR_PAIR, STAT_NODE>::const_iterator stIter;
-stIter = statTree
->
begin();
+stIter = statTree
.
begin();
-while (stIter != statTree
->
end())
+while (stIter != statTree
.
end())
{
strprintf(&tempStr,"IP='%s', dir=%d, down=%lld, up=%lld, cash=%f",
inet_ntostring(stIter->first.ip).c_str(),
{
strprintf(&tempStr,"IP='%s', dir=%d, down=%lld, up=%lld, cash=%f",
inet_ntostring(stIter->first.ip).c_str(),
@@
-1789,7
+1794,7
@@
while (stIter != statTree->end())
stIter->second.cash
);
stIter->second.cash
);
- if(
(retRes = MysqlQuery((res+tempStr).c_str(),sock)
) )
+ if(
MysqlQuery((res+tempStr).c_str(),sock
) )
{
errorStr = "Couldn't insert data in WriteDetailedStat:\n";
errorStr += mysql_error(sock);
{
errorStr = "Couldn't insert data in WriteDetailedStat:\n";
errorStr += mysql_error(sock);