bump?
-------- Doorgestuurd bericht --------
Onderwerp: request for comment - [PATCH] MEDIUM: mailer: retry sending a mail up to 3 times
Datum:  Sun, 26 Jul 2015 21:08:41 +0200
Van:    PiBa-NL <piba.nl....@gmail.com>
Aan:    HAproxy Mailing Lists <haproxy@formilux.org>


Hi guys,

Ive created a small patch that will retry sending a mail 3 times if it
fails the first time.
Its seems to work in my limited testing..

HOWEVER.
-i have not checked for memoryleaks, sockets not being closed properly
(i dont know how to..)
-is setting current and last steps to null the proper way to reset the
step of rule evaluation?
-CO_FL_ERROR is set when there is a connection error.. this seems to be
the proper check.
-but check->conn->flags & 0xFF  is a bit of s guess from observing the
flags when it could connect but the server did not respond properly.. is
there a other better way?
-i used the 'fall' variable to track the number of retries.. should i
have created a separate 'retries' variable?

Thanks for any feedback you can give me.

Best regards,
PiBa-NL



>From c5110d981cf0d2c070e88331eede15b0b16e80df Mon Sep 17 00:00:00 2001
From: Pieter Baauw <piba.nl....@gmail.com>
Date: Sun, 26 Jul 2015 20:47:27 +0200
Subject: [PATCH] MEDIUM: mailer: retry sending a mail up to 3 times

Currently only 1 connection attempt (syn packet) was send, this patch increases 
that to 3 attempts. This to make it less likely them mail is lost due to a 
single lost packet.
---
 src/checks.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/checks.c b/src/checks.c
index e386bee..cfcb1ee 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -1408,7 +1408,7 @@ static struct task *server_warmup(struct task *t)
  *
  * It can return one of :
  *  - SF_ERR_NONE if everything's OK and tcpcheck_main() was not called
- *  - SF_ERR_UP if if everything's OK and tcpcheck_main() was called
+ *  - SF_ERR_UP if everything's OK and tcpcheck_main() was called
  *  - SF_ERR_SRVTO if there are no more servers
  *  - SF_ERR_SRVCL if the connection was refused by the server
  *  - SF_ERR_PRXCOND if the connection has been limited by the proxy (maxconn)
@@ -3053,6 +3053,7 @@ static struct task *process_email_alert(struct task *t)
                        LIST_DEL(&alert->list);
 
                        check->state |= CHK_ST_ENABLED;
+                       check->fall = 0;
                }
 
        }
@@ -3060,6 +3061,16 @@ static struct task *process_email_alert(struct task *t)
        process_chk(t);
 
        if (!(check->state & CHK_ST_INPROGRESS) && check->tcpcheck_rules) {
+               if ((check->conn->flags & CO_FL_ERROR) || // connection failed, 
try again
+                       (check->conn->flags & 0xFF) // did not reach the 
'normal end', try again
+                       ) {
+                       if (check->fall < 3) {
+                               check->current_step = NULL;
+                               check->last_started_step = NULL;
+                               check->fall++;
+                               return t;
+                       }
+               }
                struct email_alert *alert;
 
                alert = container_of(check->tcpcheck_rules, typeof(*alert), 
tcpcheck_rules);
-- 
1.9.5.msysgit.1


Reply via email to