From 45b34e8abc1feff7a219354e6295f87c687aa105 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 24 Jan 2014 16:06:50 +0100 Subject: [PATCH] MINOR: connection: add more error codes to report connection errors It is quite often that an connection error only reports "socket error" with no more information. This is especially problematic with health checks where many causes are possible, including resource exhaustion which do not lead to a valid errno code. So let's add explicit codes to cover these cases. --- include/proto/connection.h | 12 ++++++++++++ include/types/connection.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/proto/connection.h b/include/proto/connection.h index 7c969eb4c..af995cd15 100644 --- a/include/proto/connection.h +++ b/include/proto/connection.h @@ -601,6 +601,18 @@ static inline const char *conn_err_code_str(struct connection *c) { switch (c->err_code) { case CO_ER_NONE: return "Success"; + + case CO_ER_CONF_FDLIM: return "Reached configured maxconn value"; + case CO_ER_PROC_FDLIM: return "Too many sockets on the process"; + case CO_ER_SYS_FDLIM: return "Too many sockets on the system"; + case CO_ER_SYS_MEMLIM: return "Out of system buffers"; + case CO_ER_NOPROTO: return "Protocol or address family not supported"; + case CO_ER_SOCK_ERR: return "General socket error"; + case CO_ER_PORT_RANGE: return "Source port range exhausted"; + case CO_ER_CANT_BIND: return "Can't bind to source address"; + case CO_ER_FREE_PORTS: return "Out of local source ports on the system"; + case CO_ER_ADDR_INUSE: return "Local source address already in use"; + case CO_ER_PRX_EMPTY: return "Connection closed while waiting for PROXY protocol header"; case CO_ER_PRX_ABORT: return "Connection error while waiting for PROXY protocol header"; case CO_ER_PRX_TIMEOUT: return "Timeout while waiting for PROXY protocol header"; diff --git a/include/types/connection.h b/include/types/connection.h index eb99cc9ac..cf93999e0 100644 --- a/include/types/connection.h +++ b/include/types/connection.h @@ -149,6 +149,19 @@ enum { /* possible connection error codes */ enum { CO_ER_NONE, /* no error */ + + CO_ER_CONF_FDLIM, /* reached process' configured FD limitation */ + CO_ER_PROC_FDLIM, /* reached process' FD limitation */ + CO_ER_SYS_FDLIM, /* reached system's FD limitation */ + CO_ER_SYS_MEMLIM, /* reached system buffers limitation */ + CO_ER_NOPROTO, /* protocol not supported */ + CO_ER_SOCK_ERR, /* other socket error */ + + CO_ER_PORT_RANGE, /* source port range exhausted */ + CO_ER_CANT_BIND, /* can't bind to source address */ + CO_ER_FREE_PORTS, /* no more free ports on the system */ + CO_ER_ADDR_INUSE, /* local address already in use */ + CO_ER_PRX_EMPTY, /* nothing received in PROXY protocol header */ CO_ER_PRX_ABORT, /* client abort during PROXY protocol header */ CO_ER_PRX_TIMEOUT, /* timeout while waiting for a PROXY header */