Skip to content

Commit 091582d

Browse files
Fixed build issues after merge
1 parent 792d40a commit 091582d

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

fineftp-server/src/ftp_session.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ namespace fineftp
184184
auto trimmed_message = me->command_output_queue_.front();
185185
trimmed_message.erase(trimmed_message.find_last_not_of("\r\n") + 1);
186186

187-
error_ << "Command write error for message " << trimmed_message << ": " << ec.message() << std::endl;
187+
me->error_ << "Command write error for message " << trimmed_message << ": " << ec.message() << std::endl;
188188
}
189189
}
190190
));

fineftp-server/src/server_impl.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
namespace fineftp
1717
{
18-
std::shared_ptr<FtpServerImpl> FtpServerImpl::create(const std::string& address, uint16_t port)
18+
std::shared_ptr<FtpServerImpl> FtpServerImpl::create(const std::string& address, uint16_t port, std::ostream& output, std::ostream& error)
1919
{
20-
return std::shared_ptr<FtpServerImpl>(new FtpServerImpl(address, port));
20+
return std::shared_ptr<FtpServerImpl>(new FtpServerImpl(address, port, output, error));
2121
}
2222

2323
FtpServerImpl::FtpServerImpl(const std::string& address, const uint16_t port, std::ostream& output, std::ostream& error)
@@ -68,18 +68,17 @@ namespace fineftp
6868
}
6969
}
7070

71-
// TODO: Add the code again to use reuse_address option
72-
//{
73-
// const std::lock_guard<std::mutex> acceptor_lock(acceptor_mutex_);
74-
75-
// asio::error_code ec;
76-
// acceptor_.set_option(asio::ip::tcp::acceptor::reuse_address(true), ec);
77-
// if (ec)
78-
// {
79-
// std::cerr << "Error setting reuse_address option: " << ec.message() << std::endl;
80-
// return false;
81-
// }
82-
//}
71+
{
72+
const std::lock_guard<std::mutex> acceptor_lock(acceptor_mutex_);
73+
74+
asio::error_code ec;
75+
acceptor_.set_option(asio::ip::tcp::acceptor::reuse_address(true), ec);
76+
if (ec)
77+
{
78+
error_ << "Error setting reuse_address option: " << ec.message() << std::endl;
79+
return false;
80+
}
81+
}
8382

8483
{
8584
const std::lock_guard<std::mutex> acceptor_lock(acceptor_mutex_);
@@ -178,7 +177,7 @@ namespace fineftp
178177
}
179178
};
180179

181-
auto new_ftp_session = std::make_shared<FtpSession>(io_service_, ftp_users_, shutdown_callback);
180+
auto new_ftp_session = std::make_shared<FtpSession>(io_service_, ftp_users_, shutdown_callback, output_, error_);
182181

183182
{
184183
const std::lock_guard<std::mutex> acceptor_lock(acceptor_mutex_);
@@ -205,7 +204,7 @@ namespace fineftp
205204
}
206205

207206
#ifndef NDEBUG
208-
output_ << "FTP Client connected: " << new_ftp_session->getSocket().remote_endpoint().address().to_string() << ":" << new_ftp_session->getSocket().remote_endpoint().port() << std::endl;
207+
me->output_ << "FTP Client connected: " << new_ftp_session->getSocket().remote_endpoint().address().to_string() << ":" << new_ftp_session->getSocket().remote_endpoint().port() << std::endl;
209208
#endif
210209
// TODO: review if this is thread safe, if right here the ftp server is shut down and the acceptor is closed. I think, that then the session will still be added to the list of open sessions and kept open.
211210

fineftp-server/src/server_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace fineftp
2121
class FtpServerImpl : public std::enable_shared_from_this<FtpServerImpl>
2222
{
2323
public:
24-
FtpServerImpl(const std::string& address, uint16_t port, std::ostream& output, std::ostream& error);
24+
static std::shared_ptr<FtpServerImpl> create(const std::string& address, uint16_t port, std::ostream& output, std::ostream& error);
2525

2626
private:
27-
FtpServerImpl(const std::string& address, uint16_t port);
27+
FtpServerImpl(const std::string& address, uint16_t port, std::ostream& output, std::ostream& error);
2828

2929
public:
3030
// Copy (disabled)

0 commit comments

Comments
 (0)