Skip to content

Commit 6dc9399

Browse files
avoid file descriptor leak
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
1 parent be5b4c7 commit 6dc9399

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

src/log.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ void open_log_fds(bool ftl)
175175
if(config.files.log.webserver.v.s != NULL)
176176
{
177177
set_log_path(&webserver_log, config.files.log.webserver.v.s);
178+
if(webserver_log.fd >= 0)
179+
close(webserver_log.fd);
178180
webserver_log.fd = open(webserver_log.path, O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, S_IRUSR|S_IWUSR|S_IRGRP);
179181
if(webserver_log.fd == -1)
180182
{
@@ -187,6 +189,8 @@ void open_log_fds(bool ftl)
187189
if(config.files.log.dnsmasq.v.s != NULL)
188190
{
189191
set_log_path(&dnsmasq_log, config.files.log.dnsmasq.v.s);
192+
if(dnsmasq_log.fd >= 0)
193+
close(dnsmasq_log.fd);
190194
dnsmasq_log.fd = open(dnsmasq_log.path, O_WRONLY|O_CREAT|O_APPEND|O_CLOEXEC, S_IRUSR|S_IWUSR|S_IRGRP);
191195
if(dnsmasq_log.fd == -1)
192196
{

0 commit comments

Comments
 (0)