mirror of
https://github.com/GOSTSec/poolserver
synced 2025-01-15 01:00:10 +00:00
Leak fix
This commit is contained in:
parent
62fcdc805a
commit
c8e00cd64d
@ -359,7 +359,6 @@ namespace Stratum
|
|||||||
sLog.Error(LOG_SERVER, "Exception caught while parsing json: %s", e.what());
|
sLog.Error(LOG_SERVER, "Exception caught while parsing json: %s", e.what());
|
||||||
}
|
}
|
||||||
_recvMessage.clear();
|
_recvMessage.clear();
|
||||||
_recvMessage.reserve(PACKET_ALLOC);
|
|
||||||
} else
|
} else
|
||||||
_recvMessage += c;
|
_recvMessage += c;
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#define PACKET_ALLOC 128
|
|
||||||
|
|
||||||
using namespace boost;
|
using namespace boost;
|
||||||
using namespace boost::asio::ip;
|
using namespace boost::asio::ip;
|
||||||
|
|
||||||
@ -31,7 +29,6 @@ namespace Stratum
|
|||||||
{
|
{
|
||||||
_diff = sConfig.Get<uint32>("StratumMinDifficulty");
|
_diff = sConfig.Get<uint32>("StratumMinDifficulty");
|
||||||
_minDiff = _diff;
|
_minDiff = _diff;
|
||||||
_recvMessage.reserve(PACKET_ALLOC);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tcp::socket& GetSocket()
|
tcp::socket& GetSocket()
|
||||||
|
@ -21,11 +21,14 @@ namespace Stratum
|
|||||||
_lastRetarget = curTime;
|
_lastRetarget = curTime;
|
||||||
|
|
||||||
// Check if miner is ok
|
// Check if miner is ok
|
||||||
if (_totalShares > 20 && (double(_totalBadShares)/double(_totalShares)) > 0.8)
|
if (_totalShares > 50 && (double(_totalBadShares)/double(_totalShares)) > 0.8)
|
||||||
_client->Ban(60);
|
_client->Ban(60);
|
||||||
|
|
||||||
while (_shares.size() && (_shares.front() < curTime - RETARGET_TIME_BUFFER))
|
while (_shares.size()) {
|
||||||
|
if (_shares.front() > curTime - RETARGET_TIME_BUFFER)
|
||||||
|
break;
|
||||||
_shares.pop_front();
|
_shares.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
uint32 interval = std::min(curTime - _startTime, uint64(RETARGET_TIME_BUFFER));
|
uint32 interval = std::min(curTime - _startTime, uint64(RETARGET_TIME_BUFFER));
|
||||||
|
|
||||||
|
@ -28,7 +28,9 @@ namespace Bitcoin
|
|||||||
mpz_t power;
|
mpz_t power;
|
||||||
mpz_init(power);
|
mpz_init(power);
|
||||||
mpz_ui_pow_ui(power, 2, 8 * (nbytes - 3));
|
mpz_ui_pow_ui(power, 2, 8 * (nbytes - 3));
|
||||||
return BigInt(bits & 0xFFFFFF) * BigInt(power);
|
BigInt result = BigInt(bits & 0xFFFFFF) * BigInt(power);
|
||||||
|
mpz_clear(power);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Transaction CreateCoinbaseTX(uint32 blockHeight, BinaryData pubkey, int64 value)
|
inline Transaction CreateCoinbaseTX(uint32 blockHeight, BinaryData pubkey, int64 value)
|
||||||
|
@ -22,6 +22,14 @@ namespace JSONReader
|
|||||||
_stack.push_back(&node);
|
_stack.push_back(&node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~SemanticFunctions()
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i+1 < _stack.size(); ++i) {
|
||||||
|
delete _stack.back();
|
||||||
|
_stack.pop_back();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void BeginObject(char ch)
|
void BeginObject(char ch)
|
||||||
{
|
{
|
||||||
if (_stack.back()->GetType() == JSON_NULL)
|
if (_stack.back()->GetType() == JSON_NULL)
|
||||||
|
@ -87,7 +87,7 @@ namespace MySQL
|
|||||||
char* buf = new char[text.length()*2 + 1];
|
char* buf = new char[text.length()*2 + 1];
|
||||||
mysql_real_escape_string(_mysql, buf, text.c_str(), text.length());
|
mysql_real_escape_string(_mysql, buf, text.c_str(), text.length());
|
||||||
std::string result(buf);
|
std::string result(buf);
|
||||||
delete buf;
|
delete[] buf;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ namespace MySQL
|
|||||||
void DatabaseQueryOperation::Execute()
|
void DatabaseQueryOperation::Execute()
|
||||||
{
|
{
|
||||||
if (_callback) {
|
if (_callback) {
|
||||||
ResultSet* result = _conn->Query(_query);
|
ResultSet* result = _conn->Query(_query.c_str());
|
||||||
_callback(QueryResult(result));
|
_callback(QueryResult(result));
|
||||||
} else
|
} else
|
||||||
_conn->Execute(_query);
|
_conn->Execute(_query.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,22 +40,15 @@ namespace MySQL
|
|||||||
class DatabaseQueryOperation : public DatabaseOperation
|
class DatabaseQueryOperation : public DatabaseOperation
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DatabaseQueryOperation(const char* query, DatabaseCallback callback = NULL): DatabaseOperation(), _callback(callback)
|
DatabaseQueryOperation(const char* query, DatabaseCallback callback = NULL): DatabaseOperation(), _callback(callback), _query(query) {}
|
||||||
{
|
|
||||||
_query = new char[strlen(query)];
|
|
||||||
strcpy(_query, const_cast<char *>(query));
|
|
||||||
}
|
|
||||||
|
|
||||||
~DatabaseQueryOperation()
|
~DatabaseQueryOperation() {}
|
||||||
{
|
|
||||||
delete[] _query;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Execute();
|
void Execute();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DatabaseCallback _callback;
|
DatabaseCallback _callback;
|
||||||
char* _query;
|
std::string _query;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Util::SynchronisedQueue<DatabaseOperation*> DatabaseWorkQueue;
|
typedef Util::SynchronisedQueue<DatabaseOperation*> DatabaseWorkQueue;
|
||||||
|
@ -104,7 +104,7 @@ namespace MySQL
|
|||||||
private:
|
private:
|
||||||
DatabaseConnection* GetSyncConnection()
|
DatabaseConnection* GetSyncConnection()
|
||||||
{
|
{
|
||||||
uint32 i;
|
uint32 i = 0;
|
||||||
uint8 conn_size = _connections[MYSQL_CONN_SYNC].size();
|
uint8 conn_size = _connections[MYSQL_CONN_SYNC].size();
|
||||||
DatabaseConnection* conn = NULL;
|
DatabaseConnection* conn = NULL;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user