mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 13:31:10 +00:00
replace boost::lexical_cast by std::to_string. std::unique_ptr for thread
This commit is contained in:
parent
a1794ccd22
commit
4f82fe24da
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
@ -15,7 +15,6 @@
|
|||||||
// Use global placeholders from boost introduced when local_time.hpp is loaded
|
// Use global placeholders from boost introduced when local_time.hpp is loaded
|
||||||
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
#define BOOST_BIND_GLOBAL_PLACEHOLDERS
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
#include "FS.h"
|
#include "FS.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
@ -30,7 +29,7 @@ namespace i2p
|
|||||||
namespace client
|
namespace client
|
||||||
{
|
{
|
||||||
I2PControlService::I2PControlService (const std::string& address, int port):
|
I2PControlService::I2PControlService (const std::string& address, int port):
|
||||||
m_IsRunning (false), m_Thread (nullptr),
|
m_IsRunning (false),
|
||||||
m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(address), port)),
|
m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint(boost::asio::ip::make_address(address), port)),
|
||||||
m_SSLContext (boost::asio::ssl::context::sslv23),
|
m_SSLContext (boost::asio::ssl::context::sslv23),
|
||||||
m_ShutdownTimer (m_Service)
|
m_ShutdownTimer (m_Service)
|
||||||
@ -98,7 +97,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
Accept ();
|
Accept ();
|
||||||
m_IsRunning = true;
|
m_IsRunning = true;
|
||||||
m_Thread = new std::thread (std::bind (&I2PControlService::Run, this));
|
m_Thread = std::make_unique<std::thread>(std::bind (&I2PControlService::Run, this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +111,6 @@ namespace client
|
|||||||
if (m_Thread)
|
if (m_Thread)
|
||||||
{
|
{
|
||||||
m_Thread->join ();
|
m_Thread->join ();
|
||||||
delete m_Thread;
|
|
||||||
m_Thread = nullptr;
|
m_Thread = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -267,7 +265,7 @@ namespace client
|
|||||||
std::ostringstream header;
|
std::ostringstream header;
|
||||||
header << "HTTP/1.1 200 OK\r\n";
|
header << "HTTP/1.1 200 OK\r\n";
|
||||||
header << "Connection: close\r\n";
|
header << "Connection: close\r\n";
|
||||||
header << "Content-Length: " << boost::lexical_cast<std::string>(len) << "\r\n";
|
header << "Content-Length: " << std::to_string(len) << "\r\n";
|
||||||
header << "Content-Type: application/json\r\n";
|
header << "Content-Type: application/json\r\n";
|
||||||
header << "Date: ";
|
header << "Date: ";
|
||||||
std::time_t t = std::time (nullptr);
|
std::time_t t = std::time (nullptr);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
@ -86,7 +86,7 @@ namespace client
|
|||||||
|
|
||||||
std::string m_Password;
|
std::string m_Password;
|
||||||
bool m_IsRunning;
|
bool m_IsRunning;
|
||||||
std::thread * m_Thread;
|
std::unique_ptr<std::thread> m_Thread;
|
||||||
|
|
||||||
boost::asio::io_context m_Service;
|
boost::asio::io_context m_Service;
|
||||||
boost::asio::ip::tcp::acceptor m_Acceptor;
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user