44
44
namespace fineftp
45
45
{
46
46
47
- FtpSession::FtpSession (asio::io_service& io_service , const UserDatabase& user_database, const std::function<void ()>& completion_handler, std::ostream& output, std::ostream& error)
47
+ FtpSession::FtpSession (asio::io_context& io_context , const UserDatabase& user_database, const std::function<void ()>& completion_handler, std::ostream& output, std::ostream& error)
48
48
: completion_handler_ (completion_handler)
49
49
, user_database_ (user_database)
50
- , io_service_ (io_service )
51
- , command_strand_ (io_service )
52
- , command_socket_ (io_service )
50
+ , io_context_ (io_context )
51
+ , command_strand_ (io_context )
52
+ , command_socket_ (io_context )
53
53
, data_type_binary_ (false )
54
54
, shutdown_requested_ (false )
55
55
, ftp_working_directory_(" /" )
56
- , data_acceptor_ (io_service )
57
- , data_socket_strand_ (io_service )
58
- , timer_ (io_service )
56
+ , data_acceptor_ (io_context )
57
+ , data_socket_strand_ (io_context )
58
+ , timer_ (io_context )
59
59
, output_(output)
60
60
, error_(error)
61
61
{
@@ -96,7 +96,7 @@ namespace fineftp
96
96
command_socket_.set_option (asio::ip::tcp::no_delay (true ), ec);
97
97
if (ec) error_ << " Unable to set socket option tcp::no_delay: " << ec.message () << std::endl;
98
98
99
- command_strand_. post ([me = shared_from_this ()]() { me->readFtpCommand (); });
99
+ asio:: post (command_strand_, [me = shared_from_this ()]() { me->readFtpCommand (); });
100
100
sendFtpMessage (FtpMessage (FtpReplyCode::SERVICE_READY_FOR_NEW_USER, " Welcome to fineFTP Server" ));
101
101
}
102
102
@@ -116,7 +116,7 @@ namespace fineftp
116
116
117
117
void FtpSession::sendRawFtpMessage (const std::string& raw_message)
118
118
{
119
- command_strand_. post ([me = shared_from_this (), raw_message]()
119
+ asio:: post (command_strand_, [me = shared_from_this (), raw_message]()
120
120
{
121
121
const bool write_in_progress = !me->command_output_queue_ .empty ();
122
122
me->command_output_queue_ .push_back (raw_message);
@@ -188,7 +188,7 @@ namespace fineftp
188
188
me->data_acceptor_ .close (ec_);
189
189
}
190
190
191
- me->data_socket_strand_ . post ( [me]()
191
+ asio::post ( me->data_socket_strand_ , [me]()
192
192
{
193
193
auto data_socket = me->data_socket_weakptr_ .lock ();
194
194
if (data_socket)
@@ -449,7 +449,7 @@ namespace fineftp
449
449
}
450
450
{
451
451
asio::error_code ec;
452
- data_acceptor_.listen (asio::socket_base::max_connections , ec);
452
+ data_acceptor_.listen (asio::socket_base::max_listen_connections , ec);
453
453
if (ec)
454
454
{
455
455
error_ << " Error listening on data acceptor: " << ec.message () << std::endl;
@@ -1205,7 +1205,7 @@ namespace fineftp
1205
1205
1206
1206
void FtpSession::sendDirectoryListing (const std::map<std::string, Filesystem::FileStatus>& directory_content)
1207
1207
{
1208
- auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_service_ );
1208
+ auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_context_ );
1209
1209
1210
1210
data_acceptor_.async_accept (*data_socket
1211
1211
, data_socket_strand_.wrap ([data_socket, directory_content, me = shared_from_this ()](auto ec)
@@ -1248,7 +1248,7 @@ namespace fineftp
1248
1248
1249
1249
void FtpSession::sendNameList (const std::map<std::string, Filesystem::FileStatus>& directory_content)
1250
1250
{
1251
- auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_service_ );
1251
+ auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_context_ );
1252
1252
1253
1253
data_acceptor_.async_accept (*data_socket
1254
1254
, data_socket_strand_.wrap ([data_socket, directory_content, me = shared_from_this ()](auto ec)
@@ -1283,7 +1283,7 @@ namespace fineftp
1283
1283
1284
1284
void FtpSession::sendFile (const std::shared_ptr<ReadableFile>& file)
1285
1285
{
1286
- auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_service_ );
1286
+ auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_context_ );
1287
1287
1288
1288
data_acceptor_.async_accept (*data_socket
1289
1289
, data_socket_strand_.wrap ([data_socket, file, me = shared_from_this ()](auto ec)
@@ -1352,7 +1352,7 @@ namespace fineftp
1352
1352
1353
1353
void FtpSession::addDataToBufferAndSend (const std::shared_ptr<std::vector<char >>& data, const std::shared_ptr<asio::ip::tcp::socket>& data_socket)
1354
1354
{
1355
- data_socket_strand_. post ([me = shared_from_this (), data, data_socket]()
1355
+ asio:: post (data_socket_strand_, [me = shared_from_this (), data, data_socket]()
1356
1356
{
1357
1357
const bool write_in_progress = (!me->data_buffer_ .empty ());
1358
1358
@@ -1367,7 +1367,7 @@ namespace fineftp
1367
1367
1368
1368
void FtpSession::writeDataToSocket (const std::shared_ptr<asio::ip::tcp::socket>& data_socket)
1369
1369
{
1370
- data_socket_strand_. post (
1370
+ asio:: post (data_socket_strand_,
1371
1371
[me = shared_from_this (), data_socket]()
1372
1372
{
1373
1373
auto data = me->data_buffer_ .front ();
@@ -1417,7 +1417,7 @@ namespace fineftp
1417
1417
1418
1418
void FtpSession::receiveFile (const std::shared_ptr<WriteableFile>& file)
1419
1419
{
1420
- auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_service_ );
1420
+ auto data_socket = std::make_shared<asio::ip::tcp::socket>(io_context_ );
1421
1421
1422
1422
data_acceptor_.async_accept (*data_socket
1423
1423
, data_socket_strand_.wrap ([data_socket, file, me = shared_from_this ()](auto ec)
@@ -1469,7 +1469,7 @@ namespace fineftp
1469
1469
1470
1470
void FtpSession::endDataReceiving (const std::shared_ptr<WriteableFile>& file, const std::shared_ptr<asio::ip::tcp::socket>& data_socket)
1471
1471
{
1472
- data_socket_strand_. post ([me = shared_from_this (), file, data_socket]()
1472
+ asio:: post (data_socket_strand_, [me = shared_from_this (), file, data_socket]()
1473
1473
{
1474
1474
file->close ();
1475
1475
me->sendFtpMessage (FtpReplyCode::CLOSING_DATA_CONNECTION, " Done" );
0 commit comments