Skip to content
Snippets Groups Projects
Commit f6f02eb5 authored by Sergey Yakubov's avatar Sergey Yakubov
Browse files

fix mem leaks

parent a7a530a3
No related branches found
No related tags found
No related merge requests found
...@@ -108,7 +108,6 @@ CurlHttpClient::~CurlHttpClient() { ...@@ -108,7 +108,6 @@ CurlHttpClient::~CurlHttpClient() {
if (curl_) { if (curl_) {
curl_easy_cleanup(curl_); curl_easy_cleanup(curl_);
} }
} }
......
...@@ -202,7 +202,7 @@ void SystemIO::CollectFileInformationRecursively(const std::string& path, ...@@ -202,7 +202,7 @@ void SystemIO::CollectFileInformationRecursively(const std::string& path,
void SystemIO::ApplyNetworkOptions(SocketDescriptor socket_fd, Error* err) const { void SystemIO::ApplyNetworkOptions(SocketDescriptor socket_fd, Error* err) const {
//TODO: Need to change network layer code, so everything can be NonBlocking //TODO: Need to change network layer code, so everything can be NonBlocking
int flag; int flag = 1;
if ( if (
/*(flags = fcntl(socket_fd, F_GETFL, 0)) == -1 /*(flags = fcntl(socket_fd, F_GETFL, 0)) == -1
|| ||
......
...@@ -10,7 +10,6 @@ enum StatisticEntity : int { ...@@ -10,7 +10,6 @@ enum StatisticEntity : int {
kDatabase = 0, kDatabase = 0,
kDisk, kDisk,
kNetwork, kNetwork,
kAuthorizer
}; };
static const std::vector<std::string> kStatisticEntityNames = {"db_share", "disk_share", "network_share"}; static const std::vector<std::string> kStatisticEntityNames = {"db_share", "disk_share", "network_share"};
......
...@@ -100,7 +100,7 @@ RequestHandlerAuthorize::RequestHandlerAuthorize(): log__{GetDefaultReceiverLogg ...@@ -100,7 +100,7 @@ RequestHandlerAuthorize::RequestHandlerAuthorize(): log__{GetDefaultReceiverLogg
} }
StatisticEntity RequestHandlerAuthorize::GetStatisticEntity() const { StatisticEntity RequestHandlerAuthorize::GetStatisticEntity() const {
return StatisticEntity::kAuthorizer; return StatisticEntity::kNetwork;
} }
......
...@@ -32,6 +32,7 @@ Error RequestsDispatcher::ProcessRequest(const std::unique_ptr<Request>& request ...@@ -32,6 +32,7 @@ Error RequestsDispatcher::ProcessRequest(const std::unique_ptr<Request>& request
Error handle_err; Error handle_err;
handle_err = request->Handle(statistics__); handle_err = request->Handle(statistics__);
GenericNetworkResponse generic_response; GenericNetworkResponse generic_response;
generic_response.op_code = request->GetOpCode();
generic_response.error_code = GetNetworkCodeFromError(handle_err); generic_response.error_code = GetNetworkCodeFromError(handle_err);
strcpy(generic_response.message, ""); strcpy(generic_response.message, "");
if (handle_err) { if (handle_err) {
......
...@@ -55,7 +55,7 @@ void Statistics::IncreaseRequestCounter() noexcept { ...@@ -55,7 +55,7 @@ void Statistics::IncreaseRequestCounter() noexcept {
Statistics::Statistics(unsigned int write_frequency) : Statistics::Statistics(unsigned int write_frequency) :
write_interval_{write_frequency} { write_interval_{write_frequency} {
statistics_sender_list__.emplace_back(new StatisticsSenderInfluxDb); statistics_sender_list__.emplace_back(std::unique_ptr<StatisticsSender> {new StatisticsSenderInfluxDb});
// statistics_sender_list__.emplace_back(new StatisticsSenderFluentd); // statistics_sender_list__.emplace_back(new StatisticsSenderFluentd);
ResetStatistics(); ResetStatistics();
} }
......
...@@ -33,6 +33,7 @@ class Statistics { ...@@ -33,6 +33,7 @@ class Statistics {
VIRTUAL void AddTag(const std::string& name, const std::string& value) noexcept; VIRTUAL void AddTag(const std::string& name, const std::string& value) noexcept;
void SetWriteInterval(uint64_t interval_ms); void SetWriteInterval(uint64_t interval_ms);
std::vector<std::unique_ptr<StatisticsSender>> statistics_sender_list__; std::vector<std::unique_ptr<StatisticsSender>> statistics_sender_list__;
virtual ~Statistics() = default;
protected: protected:
static const unsigned int kDefaultStatisticWriteIntervalMs = 10000; static const unsigned int kDefaultStatisticWriteIntervalMs = 10000;
virtual StatisticsToSend PrepareStatisticsToSend() const noexcept; virtual StatisticsToSend PrepareStatisticsToSend() const noexcept;
......
...@@ -13,6 +13,9 @@ class StatisticsSenderInfluxDb : public StatisticsSender { ...@@ -13,6 +13,9 @@ class StatisticsSenderInfluxDb : public StatisticsSender {
virtual void SendStatistics(const StatisticsToSend& statistic) const noexcept override; virtual void SendStatistics(const StatisticsToSend& statistic) const noexcept override;
std::unique_ptr<HttpClient> httpclient__; std::unique_ptr<HttpClient> httpclient__;
const AbstractLogger* log__; const AbstractLogger* log__;
~StatisticsSenderInfluxDb() {
printf("Deleting StatisticsSenderInfluxDb\n");
};
private: private:
std::string StatisticsToString(const StatisticsToSend& statistic) const noexcept; std::string StatisticsToString(const StatisticsToSend& statistic) const noexcept;
......
...@@ -148,7 +148,7 @@ class AuthorizerHandlerTests : public Test { ...@@ -148,7 +148,7 @@ class AuthorizerHandlerTests : public Test {
TEST_F(AuthorizerHandlerTests, CheckStatisticEntity) { TEST_F(AuthorizerHandlerTests, CheckStatisticEntity) {
auto entity = handler.GetStatisticEntity(); auto entity = handler.GetStatisticEntity();
ASSERT_THAT(entity, Eq(asapo::StatisticEntity::kAuthorizer)); ASSERT_THAT(entity, Eq(asapo::StatisticEntity::kNetwork));
} }
TEST_F(AuthorizerHandlerTests, ErrorNotAuthorizedYet) { TEST_F(AuthorizerHandlerTests, ErrorNotAuthorizedYet) {
......
...@@ -36,5 +36,4 @@ $1 localhost:8400 ${beamtime_id} 100 1 1 0 30 ...@@ -36,5 +36,4 @@ $1 localhost:8400 ${beamtime_id} 100 1 1 0 30
ls -ln ${receiver_folder}/1 | awk '{ print $5 }'| grep 100000 ls -ln ${receiver_folder}/1 | awk '{ print $5 }'| grep 100000
$1 localhost:8400 wrong_beamtime_id 100 1 1 0 1 2>&1 | tee /dev/stderr | grep "authorization failed"
$1 localhost:8400 wrong_beamtime_id 100 1 1 0 1 2>1 | grep "authorization failed"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment