diff src/lmtp/lmtp-proxy.c @ 17866:f21d82a32ca8

lib-lda, lmtp: Separate internal errors from remote errors. LMTP proxy shouldn't log remote errors with error level, because the proxy itself didn't have any failure. This is an API change, but I'm not aware of any plugins actually using the lmtp-client.h directly.
author Timo Sirainen <tss@iki.fi>
date Fri, 03 Oct 2014 16:31:33 +0300
parents 1b9356dbfca2
children 3db5fbb216d3
line wrap: on
line diff
--- a/src/lmtp/lmtp-proxy.c	Fri Oct 03 16:04:06 2014 +0300
+++ b/src/lmtp/lmtp-proxy.c	Fri Oct 03 16:31:33 2014 +0300
@@ -220,7 +220,8 @@
 }
 
 static void
-lmtp_proxy_conn_rcpt_to(bool success, const char *reply, void *context)
+lmtp_proxy_conn_rcpt_to(enum lmtp_client_result result,
+			const char *reply, void *context)
 {
 	struct lmtp_proxy_recipient *rcpt = context;
 	struct lmtp_proxy_connection *conn = rcpt->conn;
@@ -228,11 +229,12 @@
 	i_assert(rcpt->reply == NULL);
 
 	rcpt->reply = p_strdup(conn->proxy->pool, reply);
-	rcpt->rcpt_to_failed = !success;
+	rcpt->rcpt_to_failed = result != LMTP_CLIENT_RESULT_OK;
 }
 
 static void
-lmtp_proxy_conn_data(bool success, const char *reply, void *context)
+lmtp_proxy_conn_data(enum lmtp_client_result result,
+		     const char *reply, void *context)
 {
 	struct lmtp_proxy_recipient *rcpt = context;
 	struct lmtp_proxy_connection *conn = rcpt->conn;
@@ -247,14 +249,25 @@
 	rcpt->reply = p_strdup(conn->proxy->pool, reply);
 	rcpt->data_reply_received = TRUE;
 
-	if (!success) {
+	switch (result) {
+	case LMTP_CLIENT_RESULT_OK:
+		i_info("%s: Sent message to <%s> at %s:%u: %s",
+		       conn->proxy->set.session_id, rcpt->address,
+		       conn->set.host, conn->set.port, reply);
+		break;
+	case LMTP_CLIENT_RESULT_REMOTE_ERROR:
+		/* the problem isn't with the proxy, it's with the remote side.
+		   so the remote side will log an error, while for us this is
+		   just an info event */
+		i_info("%s: Failed to send message to <%s> at %s:%u: %s",
+		       conn->proxy->set.session_id, rcpt->address,
+		       conn->set.host, conn->set.port, reply);
+		break;
+	case LMTP_CLIENT_RESULT_INTERNAL_ERROR:
 		i_error("%s: Failed to send message to <%s> at %s:%u: %s",
 			conn->proxy->set.session_id, rcpt->address,
 			conn->set.host, conn->set.port, reply);
-	} else {
-		i_info("%s: Sent message to <%s> at %s:%u: %s",
-		       conn->proxy->set.session_id, rcpt->address,
-		       conn->set.host, conn->set.port, reply);
+		break;
 	}
 
 	lmtp_proxy_try_finish(conn->proxy);