Skip to content

Commit

Permalink
Simplify code further. This removes the if statements at the end of t…
Browse files Browse the repository at this point in the history
…he client/forward loops

Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Apr 14, 2019
1 parent cfa9120 commit 7a5eb9d
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,23 +126,13 @@ void resolveClients(bool onlynew)
// Obtain/update hostname of this client
size_t newnamepos = resolveAndAddHostname(ippos, oldnamepos);

if(newnamepos != oldnamepos)
{
// Need lock when storing obtained hostname
lock_shm();
clients[clientID].namepos = newnamepos;
clients[clientID].new = false;
newflag = false;
unlock_shm();
}
lock_shm();
// Store obtained host name (may be unchanged)
clients[clientID].namepos = newnamepos;

// Mark entry as not new even when we don't have a new host name
if(newflag)
{
lock_shm();
clients[clientID].new = false;
unlock_shm();
}
// Mark entry as not new
clients[clientID].new = false;
unlock_shm();
}
}

Expand Down Expand Up @@ -173,23 +163,12 @@ void resolveForwardDestinations(bool onlynew)
// Obtain/update hostname of this client
size_t newnamepos = resolveAndAddHostname(ippos, oldnamepos);

if(newnamepos != oldnamepos)
{
// Need lock when storing obtained hostname
lock_shm();
forwarded[forwardID].namepos = newnamepos;
forwarded[forwardID].new = false;
newflag = false;
unlock_shm();
}

lock_shm();
// Store obtained host name (may be unchanged)
forwarded[forwardID].namepos = newnamepos;
// Mark entry as not new
if(newflag)
{
lock_shm();
forwarded[forwardID].new = false;
unlock_shm();
}
forwarded[forwardID].new = false;
unlock_shm();
}
}

Expand Down

0 comments on commit 7a5eb9d

Please sign in to comment.