forked from Telodendria/Telodendria
Fix segfault in fclose() on Linux.
This commit is contained in:
parent
5af229a86e
commit
6992f36c86
3 changed files with 15 additions and 15 deletions
|
@ -167,9 +167,7 @@ HttpServerContextFree(HttpServerContext * c)
|
||||||
HashMapFree(c->requestParams);
|
HashMapFree(c->requestParams);
|
||||||
|
|
||||||
Free(c->requestPath);
|
Free(c->requestPath);
|
||||||
#if 0
|
|
||||||
fclose(c->stream);
|
fclose(c->stream);
|
||||||
#endif
|
|
||||||
|
|
||||||
Free(c);
|
Free(c);
|
||||||
}
|
}
|
||||||
|
@ -359,15 +357,15 @@ HttpServerCreate(unsigned short port, unsigned int nThreads, unsigned int maxCon
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEADDR, &ENABLE, sizeof(int)) < 0)
|
if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEADDR, &ENABLE, sizeof(int)) < 0)
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEPORT, &ENABLE, sizeof(int)) < 0)
|
if (setsockopt(server->sd, SOL_SOCKET, SO_REUSEPORT, &ENABLE, sizeof(int)) < 0)
|
||||||
{
|
{
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
sa.sin_family = AF_INET;
|
sa.sin_family = AF_INET;
|
||||||
sa.sin_port = htons(port);
|
sa.sin_port = htons(port);
|
||||||
|
@ -596,6 +594,8 @@ HttpServerWorkerThread(void *args)
|
||||||
server->requestHandler(context, server->handlerArgs);
|
server->requestHandler(context, server->handlerArgs);
|
||||||
|
|
||||||
HttpServerContextFree(context);
|
HttpServerContextFree(context);
|
||||||
|
fp = NULL; /* The above call will close this
|
||||||
|
* FILE */
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
internal_error:
|
internal_error:
|
||||||
|
@ -610,7 +610,10 @@ bad_request:
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
Free(line);
|
Free(line);
|
||||||
fclose(fp);
|
if (fp)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -144,9 +144,6 @@ MatrixHttpHandler(HttpServerContext * context, void *argp)
|
||||||
JsonFree(response);
|
JsonFree(response);
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
stream = HttpStream(context);
|
|
||||||
fclose(stream);
|
|
||||||
|
|
||||||
LogConfigUnindent(lc);
|
LogConfigUnindent(lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -211,7 +211,7 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fclose(stdin);
|
fclose(stdin);
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (unveil(configArg, "r") != 0)
|
if (unveil(configArg, "r") != 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue