Skip to content

Commit

Permalink
dnsio_tcp: minor refactoring on listen()
Browse files Browse the repository at this point in the history
This is just to satisfy the gcc-13 analyzer, which otherwise
indicates an FD leak here.  I'm guessing it can't correctly parse
listen() on a sockfd accessed from a pointer to a struct?

No functional change whatsoever.
  • Loading branch information
blblack committed Jan 4, 2024
1 parent 5277de9 commit 17ed347
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dnsio_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,11 @@ void* dnsio_tcp_start(void* thread_asvoid)
thread_t thr = { 0 };

const int backlog = (int)(addrconf->tcp_backlog ? addrconf->tcp_backlog : SOMAXCONN);
if (listen(t->sock, backlog) == -1)
const int lsock = t->sock; // copied out here just for gcc analyzer's sake
if (listen(lsock, backlog) == -1)
log_fatal("Failed to listen(s, %i) on TCP socket %s: %s", backlog, logf_anysin(&addrconf->addr), logf_errno());

set_accf(addrconf, t->sock);
set_accf(addrconf, lsock);

pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);

Expand All @@ -1056,7 +1057,7 @@ void* dnsio_tcp_start(void* thread_asvoid)
idle_watcher->data = &thr;

ev_io* accept_watcher = &thr.accept_watcher;
ev_io_init(accept_watcher, accept_handler, t->sock, EV_READ);
ev_io_init(accept_watcher, accept_handler, lsock, EV_READ);
ev_set_priority(accept_watcher, -1);
accept_watcher->data = &thr;

Expand Down

0 comments on commit 17ed347

Please sign in to comment.