From 514350ae81c02e9059f045e2d96da4cea6f3614a Mon Sep 17 00:00:00 2001 From: "huheng@kylinos.cn" Date: Tue, 4 Apr 2023 10:25:59 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix(=E6=96=87=E4=BB=B6=E4=BC=A0?= =?UTF-8?q?=E8=BE=93):=20=E4=BC=98=E5=8C=96ftp=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ftpserver/fineftp-server/src/ftp_session.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/3rdparty/ftpserver/fineftp-server/src/ftp_session.cpp b/3rdparty/ftpserver/fineftp-server/src/ftp_session.cpp index d8afc69..ec50b2c 100755 --- a/3rdparty/ftpserver/fineftp-server/src/ftp_session.cpp +++ b/3rdparty/ftpserver/fineftp-server/src/ftp_session.cpp @@ -1125,7 +1125,8 @@ void FtpSession::writeDataToSocket(std::shared_ptr 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 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]() {