identd: Rework lowestSocketId handling
authorJan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Sat, 19 May 2018 10:31:40 +0000 (12:31 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 18 Jun 2018 19:25:50 +0000 (21:25 +0200)
commit4e6582c9640179cb195126d7f7ee363faf9fe42e
tree21acb77dc74cff4e3d0de2b4ce116f05e97c91ec
parenta5ee609b02cb8d7ebb43b0034a6d50838c426f0b
identd: Rework lowestSocketId handling

Since we're appending only strictly increasing integers, the lowest
socketId is always at the front of the list (if that exists).

hasSocketsBelowId also had a off-by-one error. This had no effect on the
code since a socketId equal to the current _socketId cannot be in the
_waiting list.

Reorder processWaiting's handling of requests:
  - If the socketId is one the request might have been waiting for,
    check responseAvailable.
  - Otherwise, if there is at least one socket we need to wait for,
    continue waiting.
  - Otherwise, responseUnavailable.

The former order was:
  - If there are no sockets left from before this request was made,
    responseUnavailable.
  - If the socketId is one the request might have been waiting for,
    check responseAvailable.
  - Otherwise, continue waiting.

The change was necessary as the lowestSocketId no longer includes the
socketId that was just removed. In addition, the new order also matches
the if-else chain in IdentServer::respond.
src/core/identserver.cpp
src/core/identserver.h