🐞 fix(文件传输): 优化ftp服务器端口管理
This commit is contained in:
parent
0fd9287508
commit
514350ae81
|
@ -1125,7 +1125,8 @@ void FtpSession::writeDataToSocket(std::shared_ptr<asio::ip::tcp::socket> data_s
|
|||
// we got to the end of transmission
|
||||
me->data_buffer_.pop_front();
|
||||
me->sendFtpMessage(FtpReplyCode::CLOSING_DATA_CONNECTION, "Done");
|
||||
s_freePorts.push(port);
|
||||
auto nowPort = data_socket->local_endpoint().port();
|
||||
s_freePorts.push(nowPort);
|
||||
data_socket->close();
|
||||
if (me->getAcceptor().is_open()) {
|
||||
std::cout << "acceptor is open" << std::endl;
|
||||
|
@ -1171,6 +1172,17 @@ void FtpSession::receiveDataFromSocketAndWriteToFile(std::shared_ptr<IoFile> fil
|
|||
me->writeDataToFile(buffer, file);
|
||||
}
|
||||
me->endDataReceiving(file);
|
||||
auto nowPort = data_socket->local_endpoint().port();
|
||||
s_freePorts.push(nowPort);
|
||||
data_socket->close();
|
||||
if (me->getAcceptor().is_open()) {
|
||||
std::cout << "acceptor is open" << std::endl;
|
||||
asio::error_code ec;
|
||||
me->getAcceptor().close(ec);
|
||||
if (ec) {
|
||||
std::cerr << "Error closing data acceptor: " << ec.message() << std::endl;
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (length > 0) {
|
||||
me->writeDataToFile(buffer, file, [me, file, data_socket]() {
|
||||
|
|
Loading…
Reference in New Issue