Improve the file response performance
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>main^2
parent
f32ae1188a
commit
805b1589f0
|
@ -1 +1 @@
|
||||||
Subproject commit 84e1b93c110b8a886fadab0563319506edb66741
|
Subproject commit 1bd1b6d192eda9e5bc24582e7ef3a4a017f9b064
|
|
@ -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 uh_connection_internal *conni = (struct uh_connection_internal *)conn;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
int ret;
|
||||||
|
|
||||||
conni->file.fd = open(path, O_RDONLY);
|
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;
|
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);
|
ev_io_start(conni->srv->loop, &conni->iow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue