]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Cleanup - move code to a new director_log_connect()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 14 Sep 2017 14:33:19 +0000 (17:33 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 5 Oct 2017 14:45:38 +0000 (17:45 +0300)
Also adds a missing ')' to the log line.

src/director/director.c

index 0d31003e5e402c5f613b1d0c4cfe4c6ce2b35b61..536a1e45f72bfaae687a68624450cb9424c86374 100644 (file)
@@ -128,6 +128,24 @@ director_has_outgoing_connection(struct director *dir,
        return FALSE;
 }
 
+static void
+director_log_connect(struct director *dir, struct director_host *host)
+{
+       string_t *str = t_str_new(128);
+
+       if (host->last_network_failure > 0) {
+               str_printfa(str, ", last network failure %ds ago",
+                           (int)(ioloop_time - host->last_network_failure));
+       }
+       if (host->last_protocol_failure > 0) {
+               str_printfa(str, ", last protocol failure %ds ago",
+                           (int)(ioloop_time - host->last_protocol_failure));
+       }
+       dir_debug("Connecting to %s:%u (as %s%s)",
+                 net_ip2addr(&host->ip), host->port,
+                 net_ip2addr(&dir->self_ip), str_c(str));
+}
+
 int director_connect_host(struct director *dir, struct director_host *host)
 {
        in_port_t port;
@@ -136,22 +154,8 @@ int director_connect_host(struct director *dir, struct director_host *host)
        if (director_has_outgoing_connection(dir, host))
                return 0;
 
-       if (director_debug) {
-               string_t *str = t_str_new(128);
-
-               str_printfa(str, "Connecting to %s:%u (as %s",
-                           net_ip2addr(&host->ip), host->port,
-                           net_ip2addr(&dir->self_ip));
-               if (host->last_network_failure > 0) {
-                       str_printfa(str, ", last network failure %ds ago",
-                                   (int)(ioloop_time - host->last_network_failure));
-               }
-               if (host->last_protocol_failure > 0) {
-                       str_printfa(str, ", last protocol failure %ds ago",
-                                   (int)(ioloop_time - host->last_protocol_failure));
-               }
-               dir_debug("%s", str_c(str));
-       }
+       if (director_debug)
+               director_log_connect(dir, host);
        port = dir->test_port != 0 ? dir->test_port : host->port;
        fd = net_connect_ip(&host->ip, port, &dir->self_ip);
        if (fd == -1) {