Fixed a bug with CPU usage

This commit is contained in:
root
2022-01-30 23:27:49 -06:00
parent e1a66999b6
commit 9f39edd186
2 changed files with 13 additions and 6 deletions

View File

@@ -93,7 +93,11 @@ static int readResponse(Connection *conn, char *path) {
off_t len = lseek(fd, 0, SEEK_END);
if (len < 0)
goto error;
lseek(fd, 0, SEEK_SET);
if (lseek(fd, 0, SEEK_SET) < 0) {
sendErrorResponse(conn, ERROR_500);
close(fd);
return -1;
}
sendHeader(conn, CODE_200, len);
conn->len = len;
return fd;