Skip to content

Commit

Permalink
Use newflag instead of .new booleans to avoid needing a further lock
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Apr 14, 2019
1 parent b29b9ab commit cfa9120
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ void resolveClients(bool onlynew)

// Memory access needs to get locked
lock_shm();
bool newlock = clients[clientID].new;
bool newflag = clients[clientID].new;
size_t ippos = clients[clientID].ippos;
size_t oldnamepos = clients[clientID].namepos;
unlock_shm();

// If onlynew flag is set, we will only resolve new clients
// If not, we will try to re-resolve all known clients
if(onlynew && !newlock)
if(onlynew && !newflag)
continue;

// Obtain/update hostname of this client
Expand All @@ -132,11 +132,12 @@ void resolveClients(bool onlynew)
lock_shm();
clients[clientID].namepos = newnamepos;
clients[clientID].new = false;
newflag = false;
unlock_shm();
}

// Mark entry as not new even when we don't have a new host name
if(clients[clientID].new)
if(newflag)
{
lock_shm();
clients[clientID].new = false;
Expand Down Expand Up @@ -178,11 +179,12 @@ void resolveForwardDestinations(bool onlynew)
lock_shm();
forwarded[forwardID].namepos = newnamepos;
forwarded[forwardID].new = false;
newflag = false;
unlock_shm();
}

// Mark entry as not new
if(forwarded[forwardID].new)
if(newflag)
{
lock_shm();
forwarded[forwardID].new = false;
Expand Down

0 comments on commit cfa9120

Please sign in to comment.