mirror of
https://github.com/fumiama/simple-kanban.git
synced 2026-06-15 22:50:26 +08:00
修复linux sendfile语法
This commit is contained in:
3
server.c
3
server.c
@@ -126,6 +126,7 @@ int sendAll(char* file_path, THREADTIMER *timer) {
|
||||
timer->fp = fp;
|
||||
timer->is_open = 1;
|
||||
uint32_t file_size = (uint32_t)fileSize(file_path);
|
||||
printf("Get file size: %u bytes.\n", file_size);
|
||||
off_t len;
|
||||
#if __APPLE__
|
||||
struct iovec headers;
|
||||
@@ -136,7 +137,7 @@ int sendAll(char* file_path, THREADTIMER *timer) {
|
||||
sendfile(fileno(fp), timer->accept_fd, 0, &len, &hdtr, 0);
|
||||
#else
|
||||
send(timer->accept_fd, &file_size, sizeof(uint32_t), 0);
|
||||
sendfile(timer->accept_fd, fileno(fp), &len, file_size);
|
||||
sendfile(timer->accept_fd, fileno(fp), &len, htonl(file_size));
|
||||
#endif
|
||||
printf("Send %lld bytes.\n", len);
|
||||
closeFile(fp);
|
||||
|
||||
Reference in New Issue
Block a user