Improve the file response performance
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
1 parent
f32ae1188a
commit
805b1589f0
2 files changed
+6
-1
No files matched your search
+1
-1
Submodule src/buffer updated: 84e1b93c11...1bd1b6d192.
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user