1
0
mirror of https://github.com/fumiama/simple-http-server.git synced 2026-06-05 00:30:23 +08:00

readline改用sendfile

This commit is contained in:
源文雨
2021-06-08 14:32:28 +08:00
parent 40de9c8f93
commit b660869a17

View File

@@ -263,8 +263,16 @@ static void execute_cgi(int client, const char *path, const char *method, const
i += cnt; i += cnt;
} }
} }
int cnt = 0; uint32_t cnt = 0;
while ((cnt = read(cgi_output[0], buf, 1024)) > 0) send(client, buf, cnt, 0); read(cgi_output[0], (char*)&cnt, sizeof(uint32_t));
if(cnt > 0) {
int len = 0;
#if __APPLE__
sendfile(cgi_output[0], client, 0, &len, &hdtr, 0);
#else
sendfile(client, cgi_output[0], &len, cnt);
#endif
}
close(cgi_output[0]); close(cgi_output[0]);
close(cgi_input[1]); close(cgi_input[1]);