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:
12
server.c
12
server.c
@@ -263,8 +263,16 @@ static void execute_cgi(int client, const char *path, const char *method, const
|
||||
i += cnt;
|
||||
}
|
||||
}
|
||||
int cnt = 0;
|
||||
while ((cnt = read(cgi_output[0], buf, 1024)) > 0) send(client, buf, cnt, 0);
|
||||
uint32_t 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_input[1]);
|
||||
|
||||
Reference in New Issue
Block a user