diff --git a/src/HttpServer.c b/src/HttpServer.c index 0f390c6..908627a 100644 --- a/src/HttpServer.c +++ b/src/HttpServer.c @@ -167,9 +167,7 @@ HttpServerContextFree(HttpServerContext * c) HashMapFree(c->requestParams); Free(c->requestPath); -#if 0 fclose(c->stream); -#endif Free(c); } @@ -359,15 +357,15 @@ HttpServerCreate(unsigned short port, unsigned int nThreads, unsigned int maxCon goto error; } - if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEADDR, &ENABLE, sizeof(int)) < 0) - { - goto error; - } + if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEADDR, &ENABLE, sizeof(int)) < 0) + { + goto error; + } - if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEPORT, &ENABLE, sizeof(int)) < 0) - { - goto error; - } + if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEPORT, &ENABLE, sizeof(int)) < 0) + { + goto error; + } sa.sin_family = AF_INET; sa.sin_port = htons(port); @@ -596,6 +594,8 @@ HttpServerWorkerThread(void *args) server->requestHandler(context, server->handlerArgs); HttpServerContextFree(context); + fp = NULL; /* The above call will close this + * FILE */ goto finish; internal_error: @@ -610,7 +610,10 @@ bad_request: finish: Free(line); - fclose(fp); + if (fp) + { + fclose(fp); + } } return NULL; diff --git a/src/Matrix.c b/src/Matrix.c index 88f5d78..2589eb9 100644 --- a/src/Matrix.c +++ b/src/Matrix.c @@ -144,9 +144,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp) JsonFree(response); finish: - stream = HttpStream(context); - fclose(stream); - LogConfigUnindent(lc); } diff --git a/src/Telodendria.c b/src/Telodendria.c index d0ff212..e489ac0 100644 --- a/src/Telodendria.c +++ b/src/Telodendria.c @@ -211,7 +211,7 @@ main(int argc, char **argv) } else { - fclose(stdin); + fclose(stdin); #ifdef __OpenBSD__ if (unveil(configArg, "r") != 0) {