mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Networking: speed up sendfile download
use a multiple of sector size and DMA safe memory
This commit is contained in:
parent
c5f295e852
commit
b0bbed01c6
@ -293,7 +293,15 @@ bool AP_Networking::sendfile(SocketAPM *sock, int fd)
|
|||||||
{
|
{
|
||||||
WITH_SEMAPHORE(sem);
|
WITH_SEMAPHORE(sem);
|
||||||
if (sendfile_buf == nullptr) {
|
if (sendfile_buf == nullptr) {
|
||||||
sendfile_buf = (uint8_t *)malloc(AP_NETWORKING_SENDFILE_BUFSIZE);
|
uint32_t bufsize = AP_NETWORKING_SENDFILE_BUFSIZE;
|
||||||
|
do {
|
||||||
|
sendfile_buf = (uint8_t *)hal.util->malloc_type(bufsize, AP_HAL::Util::MEM_FILESYSTEM);
|
||||||
|
if (sendfile_buf != nullptr) {
|
||||||
|
sendfile_bufsize = bufsize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
bufsize /= 2;
|
||||||
|
} while (bufsize >= 4096);
|
||||||
if (sendfile_buf == nullptr) {
|
if (sendfile_buf == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -344,7 +352,7 @@ void AP_Networking::sendfile_check(void)
|
|||||||
if (!s.sock->pollout(0)) {
|
if (!s.sock->pollout(0)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto nread = AP::FS().read(s.fd, sendfile_buf, AP_NETWORKING_SENDFILE_BUFSIZE);
|
const auto nread = AP::FS().read(s.fd, sendfile_buf, sendfile_bufsize);
|
||||||
if (nread <= 0) {
|
if (nread <= 0) {
|
||||||
s.close();
|
s.close();
|
||||||
continue;
|
continue;
|
||||||
|
@ -278,6 +278,7 @@ private:
|
|||||||
} sendfiles[AP_NETWORKING_NUM_SENDFILES];
|
} sendfiles[AP_NETWORKING_NUM_SENDFILES];
|
||||||
|
|
||||||
uint8_t *sendfile_buf;
|
uint8_t *sendfile_buf;
|
||||||
|
uint32_t sendfile_bufsize;
|
||||||
void sendfile_check(void);
|
void sendfile_check(void);
|
||||||
bool sendfile_thread_started;
|
bool sendfile_thread_started;
|
||||||
|
|
||||||
|
@ -117,5 +117,5 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef AP_NETWORKING_SENDFILE_BUFSIZE
|
#ifndef AP_NETWORKING_SENDFILE_BUFSIZE
|
||||||
#define AP_NETWORKING_SENDFILE_BUFSIZE 10000
|
#define AP_NETWORKING_SENDFILE_BUFSIZE (64*512)
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user