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]() {