BUG/MINOR: listener: Don't decrease actconn twice when a new session is rejected
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 23 Mar 2018 14:11:55 +0000 (15:11 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 23 Mar 2018 15:21:50 +0000 (16:21 +0100)
commitfe234281d6cf0de8d16a630092a89c25b9fd27f7
tree59084299089f4851eebebc249f5b402ce179216d
parent8adae7c15ffb5df8fcbb41496735fef25d6c4df3
BUG/MINOR: listener: Don't decrease actconn twice when a new session is rejected

When a freshly created session is rejected, for any reason, during the accept in
the function "session_accept_fd", the variable "actconn" is decreased twice. The
first time when the rejected session is released, then in the function
"listener_accpect", because of the failure. So it is possible to have an
negative value for actconn. Note that, in this case, we will also have a negatve
value for the current number of connections on the listener rejecting the
session (actconn and l->nbconn are in/decreased in same time).

It is easy to reproduce the bug with this small configuration:

  global
      stats socket /tmp/haproxy

  listen test
      bind *:12345
      tcp-request connection reject if TRUE

A "show info" on the stat socket, after a connection attempt, will show a very
high value (the unsigned representation of -1).

To fix the bug, if the function "session_accept_fd" returns an error, it
decrements the right counters and "listener_accpect" leaves them untouched.

This patch must be backported in 1.8.
src/listener.c
src/session.c