Fix fd leak for cached static files

This commit is contained in:
cpq 2021-01-03 09:39:46 +00:00
parent e135743efa
commit 117aeaa15d
2 changed files with 2 additions and 0 deletions

View File

@ -786,6 +786,7 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
mg_http_etag(etag, sizeof(etag), &st) != etag) {
mg_http_reply(c, 404, "", "%s", "Not found\n");
} else if (inm != NULL && mg_vcasecmp(inm, etag) == 0) {
fclose(fp);
mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n");
} else {
mg_printf(c,

View File

@ -372,6 +372,7 @@ void mg_http_serve_file(struct mg_connection *c, struct mg_http_message *hm,
mg_http_etag(etag, sizeof(etag), &st) != etag) {
mg_http_reply(c, 404, "", "%s", "Not found\n");
} else if (inm != NULL && mg_vcasecmp(inm, etag) == 0) {
fclose(fp);
mg_printf(c, "HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n");
} else {
mg_printf(c,