内存管理文档4→2合并:报告/规划并入主文档,lftpd静态化降栈峰值,同步架构/FTP/部署文档

This commit is contained in:
2026-09-21 04:37:27 +08:00
parent bbdd059e25
commit 57632e910a
14 changed files with 394 additions and 626 deletions
+9 -9
View File
@@ -66,8 +66,8 @@ static int send_response(int socket, int code, bool include_code,
bool multiline_start, const char *format, ...)
{
va_list args;
char message[256];
char response[512];
static char message[256]; /* static: off-stack, single-client ftpTask */
static char response[512]; /* static: off-stack, single-client ftpTask */
va_start(args, format);
vsnprintf(message, sizeof(message), format, args);
@@ -108,7 +108,7 @@ static int send_list(int socket, const char *path)
return -1;
}
char name[256];
static char name[256]; /* static: off-stack, single-client ftpTask */
uint32_t size;
int is_dir;
@@ -133,7 +133,7 @@ static int send_nlst(int socket, const char *path)
return -1;
}
char name[256];
static char name[256]; /* static: off-stack, single-client ftpTask */
uint32_t size;
int is_dir;
@@ -155,7 +155,7 @@ static int send_file(int socket, const char *path)
return -1;
}
unsigned char buffer[1024];
static unsigned char buffer[1024]; /* static: 1KB off-stack, single-client ftpTask */
int read_len;
while ((read_len = lftpd_io_read(fh, buffer, sizeof(buffer))) > 0) {
@@ -184,7 +184,7 @@ static int receive_file(int socket, const char *path)
return -1;
}
unsigned char buffer[1024];
static unsigned char buffer[1024]; /* static: 1KB off-stack, single-client ftpTask */
int err;
int total = 0;
@@ -550,7 +550,7 @@ static int handle_control_channel(lftpd_client_t *client)
goto cleanup;
}
char read_buffer[512];
static char read_buffer[512]; /* static: off-stack, single-client ftpTask */
while (err == 0) {
int line_len = lftpd_inet_read_line(client->socket, read_buffer,
@@ -584,7 +584,7 @@ static int handle_control_channel(lftpd_client_t *client)
bool matched = false;
for (int i = 0; commands[i].command; i++) {
if (strcmp(commands[i].command, command_tmp) == 0) {
char arg_buf[512];
static char arg_buf[512]; /* static: off-stack, single-client ftpTask */
const char *arg = NULL;
if (index < (int)strlen(read_buffer)) {
@@ -649,7 +649,7 @@ int lftpd_start(const char *directory, int port, lftpd_t *lftpd)
}
}
lftpd_client_t client;
static lftpd_client_t client; /* static: off-stack session context (single session) */
memset(&client, 0, sizeof(client));
strncpy(client.directory, directory, sizeof(client.directory) - 1);
client.directory[sizeof(client.directory) - 1] = '\0';