Improve the file response performance

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao committed 2021-01-02 19:22:07 +08:00
1 parent f32ae1188a
commit 805b1589f0
2 files changed
+6 -1

No files matched your search

+5
View File
@@ -66,6 +66,7 @@ static void conn_send_file(struct uh_connection *conn, const char *path)
{
struct uh_connection_internal *conni = (struct uh_connection_internal *)conn;
struct stat st;
int ret;
conni->file.fd = open(path, O_RDONLY);
@@ -73,6 +74,10 @@ static void conn_send_file(struct uh_connection *conn, const char *path)
conni->file.size = st.st_size;
/* If the file is not greater than 8K, then append it to the HTTP head, send once */
ret = buffer_put_fd(&conni->wb, conni->file.fd, 8192, NULL);
conni->file.size -= ret;
ev_io_start(conni->srv->loop, &conni->iow);
}