mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-22 01:12:31 +00:00
mavlink_ftp: close session without activity
10s inactivity timeout to close session
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include <v2.0/standard/mavlink.h>
|
||||
#endif
|
||||
|
||||
using namespace time_literals;
|
||||
|
||||
constexpr const char MavlinkFTP::_root_dir[];
|
||||
|
||||
@@ -960,7 +961,7 @@ void MavlinkFTP::send(const hrt_abstime t)
|
||||
|
||||
if (_work_buffer1 || _work_buffer2) {
|
||||
// free the work buffers if they are not used for a while
|
||||
if (hrt_elapsed_time(&_last_work_buffer_access) > 2000000) {
|
||||
if (hrt_elapsed_time(&_last_work_buffer_access) > 2_s) {
|
||||
if (_work_buffer1) {
|
||||
delete[] _work_buffer1;
|
||||
_work_buffer1 = nullptr;
|
||||
@@ -971,6 +972,16 @@ void MavlinkFTP::send(const hrt_abstime t)
|
||||
_work_buffer2 = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (_session_info.fd != -1) {
|
||||
// close session without activity
|
||||
if (hrt_elapsed_time(&_last_work_buffer_access) > 10_s) {
|
||||
::close(_session_info.fd);
|
||||
_session_info.fd = -1;
|
||||
_session_info.stream_download = false;
|
||||
_last_reply_valid = false;
|
||||
PX4_WARN("Session was closed without activity");
|
||||
}
|
||||
}
|
||||
|
||||
// Anything to stream?
|
||||
|
||||
Reference in New Issue
Block a user