diff --git a/src/HttpServer.c b/src/HttpServer.c index 35af7bc..1b9cc58 100644 --- a/src/HttpServer.c +++ b/src/HttpServer.c @@ -165,7 +165,9 @@ HttpServerContextFree(HttpServerContext * c) HashMapFree(c->requestParams); Free(c->requestPath); +#if 0 fclose(c->stream); +#endif Free(c); } @@ -513,7 +515,7 @@ HttpServerWorkerThread(void *args) } requestPath[i] = '\0'; - requestParams = HttpParamDecode(requestPath + i + 1); + requestParams = HttpParamDecode(requestPath + i); context = HttpServerContextCreate(requestMethod, requestPath, requestParams, fp); if (!context) @@ -596,7 +598,9 @@ bad_request: finish: Free(line); +#if 0 fclose(fp); +#endif } return NULL; diff --git a/src/Memory.c b/src/Memory.c index 5f9eb43..d9844f9 100644 --- a/src/Memory.c +++ b/src/Memory.c @@ -334,12 +334,13 @@ MemoryInfoGet(void *p) } else { - break; + pthread_mutex_unlock(&lock); + return allocations[hash]; } } pthread_mutex_unlock(&lock); - return allocations[hash]; + return NULL; } size_t diff --git a/src/Telodendria.c b/src/Telodendria.c index 55ec45b..7f6e229 100644 --- a/src/Telodendria.c +++ b/src/Telodendria.c @@ -154,7 +154,6 @@ main(int argc, char **argv) memset(&matrixArgs, 0, sizeof(matrixArgs)); lc = LogConfigCreate(); - LogConfigLevelSet(lc, LOG_DEBUG); if (!lc) { @@ -212,6 +211,7 @@ main(int argc, char **argv) } else { + fclose(stdin); #ifdef __OpenBSD__ if (unveil(configArg, "r") != 0) { @@ -472,6 +472,16 @@ finish: HttpServerFree(httpServer); Log(lc, LOG_DEBUG, "Freed HTTP Server."); } + + /* + * If we're not logging to standard output, then we can close it. Otherwise, + * if we are logging to stdout, LogConfigFree() will close it for us. + */ + if (!(tConfig->flags & TELODENDRIA_LOG_STDOUT)) + { + fclose(stdout); + } + TelodendriaConfigFree(tConfig); DbClose(matrixArgs.db); @@ -483,5 +493,7 @@ finish: LogConfigFree(lc); MemoryFreeAll(); + + fclose(stderr); return exit; }