[MINOR] Add down termination condition
If a connection is closed by because the backend became unavailable
then log 'D' as the termination condition.
Signed-off-by: Simon Horman <horms@verge.net.au>
diff --git a/doc/configuration.txt b/doc/configuration.txt
index f397f41..b28e851 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -8725,6 +8725,9 @@
would be wise to preventively restart the process after such an
event too, in case it would be caused by memory corruption.
+ D : the session was killed by haproxy because the server was detected
+ as down and was configured to kill all connections when going down.
+
c : the client-side timeout expired while waiting for the client to
send or receive data.
diff --git a/include/types/session.h b/include/types/session.h
index 7fde0aa..6054924 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -65,9 +65,9 @@
#define SN_ERR_PRXCOND 0x00005000 /* the proxy decided to close (deny...) */
#define SN_ERR_RESOURCE 0x00006000 /* the proxy encountered a lack of a local resources (fd, mem, ...) */
#define SN_ERR_INTERNAL 0x00007000 /* the proxy encountered an internal error */
-#define SN_ERR_MASK 0x00007000 /* mask to get only session error flags */
+#define SN_ERR_DOWN 0x00008000 /* the proxy killed a session because the backend became unavailable */
+#define SN_ERR_MASK 0x0000f000 /* mask to get only session error flags */
#define SN_ERR_SHIFT 12 /* bit shift */
-#define SN_BE_TRACK_SC1 0x00008000 /* backend tracks stick-counter 1 */
/* session state at termination, bits values 0x10000 to 0x70000 (0-7 shift 16) */
#define SN_FINST_R 0x00010000 /* session ended during client request */
@@ -79,9 +79,10 @@
#define SN_FINST_T 0x00070000 /* session ended tarpitted */
#define SN_FINST_MASK 0x00070000 /* mask to get only final session state flags */
#define SN_FINST_SHIFT 16 /* bit shift */
-#define SN_BE_TRACK_SC2 0x00080000 /* backend tracks stick-counter 2 */
-#define SN_IGNORE_PRST 0x00100000 /* ignore persistence */
+#define SN_IGNORE_PRST 0x00080000 /* ignore persistence */
+#define SN_BE_TRACK_SC1 0x00100000 /* backend tracks stick-counter 1 */
+#define SN_BE_TRACK_SC2 0x00200000 /* backend tracks stick-counter 2 */
/* Termination sequence tracing.
*
diff --git a/src/checks.c b/src/checks.c
index 6b34a37..5bcf47c 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -371,6 +371,8 @@
buffer_shutw_now(session->req);
buffer_shutr_now(session->rep);
session->task->nice = 1024;
+ if (!(session->flags & SN_ERR_MASK))
+ session->flags |= SN_ERR_DOWN;
task_wakeup(session->task, TASK_WOKEN_OTHER);
}
}
diff --git a/src/log.c b/src/log.c
index 58d884a..02b6b20 100644
--- a/src/log.c
+++ b/src/log.c
@@ -52,7 +52,7 @@
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};
-const char sess_term_cond[8] = "-cCsSPRI"; /* normal, CliTo, CliErr, SrvTo, SrvErr, PxErr, Resource, Internal */
+const char sess_term_cond[9] = "-cCsSPRID"; /* normal, CliTo, CliErr, SrvTo, SrvErr, PxErr, Resource, Internal, Down */
const char sess_fin_state[8] = "-RCHDLQT"; /* cliRequest, srvConnect, srvHeader, Data, Last, Queue, Tarpit */
/*