From: Timo Sirainen Date: Thu, 31 Oct 2019 17:10:22 +0000 (+0200) Subject: director: Replace i_warning() and i_info() logging with e_*() X-Git-Tag: 2.3.13~377 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2795b4f95e380e5378c1af30d20ec847ca6dccc0;p=thirdparty%2Fdovecot%2Fcore.git director: Replace i_warning() and i_info() logging with e_*() --- diff --git a/src/director/director-connection.c b/src/director/director-connection.c index 8269296e4d..b1a4b2909b 100644 --- a/src/director/director-connection.c +++ b/src/director/director-connection.c @@ -320,7 +320,8 @@ static bool director_connection_assign_left(struct director_connection *conn) } else if (dir->left == NULL) { /* no conflicts yet */ } else if (dir->left->host == conn->host) { - i_warning("Replacing left director connection %s with %s", + e_warning(dir->event, + "Replacing left director connection %s with %s", dir->left->host->name, conn->host->name); director_connection_deinit(&dir->left, t_strdup_printf( "Replacing with %s", conn->host->name)); @@ -415,13 +416,15 @@ static bool director_connection_assign_right(struct director_connection *conn) if (director_host_cmp_to_self(conn->host, dir->right->host, dir->self_host) <= 0) { /* the old connection is the correct one */ - i_warning("Aborting incorrect outgoing connection to %s " + e_warning(dir->event, + "Aborting incorrect outgoing connection to %s " "(already connected to correct one: %s)", conn->host->name, dir->right->host->name); conn->wrong_host = TRUE; return FALSE; } - i_warning("Replacing right director connection %s with %s", + e_warning(dir->event, + "Replacing right director connection %s with %s", dir->right->host->name, conn->host->name); director_connection_deinit(&dir->right, t_strdup_printf( "Replacing with %s", conn->host->name)); @@ -492,7 +495,8 @@ static bool director_cmd_me(struct director_connection *conn, diff = ioloop_time - remote_time; if (diff > DIRECTOR_MAX_CLOCK_DIFF_WARN_SECS || (diff < 0 && -diff > DIRECTOR_MAX_CLOCK_DIFF_WARN_SECS)) { - i_warning("Director %s clock differs from ours by %d secs", + e_warning(dir->event, + "Director %s clock differs from ours by %d secs", conn->name, diff); } } @@ -1176,7 +1180,7 @@ director_cmd_host_int(struct director_connection *conn, const char *const *args, vhost_count = I_MIN(vhost_count, host->vhost_count); str_printfa(str, "setting to state=%s vhosts=%u", down ? "down" : "up", vhost_count); - i_warning("%s", str_c(str)); + e_warning(conn->dir->event, "%s", str_c(str)); /* make the change appear to come from us, so it reaches the full ring */ dir_host = NULL; @@ -1429,9 +1433,9 @@ static bool director_handshake_cmd_done(struct director_connection *conn) director_connection_append_stats(conn, str); str_append_c(str, ')'); if (handshake_msecs >= DIRECTOR_HANDSHAKE_WARN_SECS*1000) - i_warning("%s", str_c(str)); + e_warning(dir->event, "%s", str_c(str)); else - i_info("%s", str_c(str)); + e_info(dir->event, "%s", str_c(str)); /* the host is up now, make sure we can connect to it immediately if needed */ @@ -1617,7 +1621,8 @@ director_connection_sync_host(struct director_connection *conn, timestamp); return FALSE; } else if (seq < host->last_sync_seq) { - i_warning("Last SYNC seq for %s appears to be stale, resetting " + e_warning(dir->event, + "Last SYNC seq for %s appears to be stale, resetting " "(seq=%u, timestamp=%u -> seq=%u, timestamp=%u)", host->name, host->last_sync_seq, host->last_sync_timestamp, seq, timestamp); @@ -1846,7 +1851,8 @@ static bool director_cmd_ping(struct director_connection *conn, str_to_uintmax(args[1], &send_buffer_size) == 0) { int diff_secs = ioloop_time - sent_time; if (diff_secs*1000+500 > DIRECTOR_CONNECTION_PINGPONG_WARN_MSECS) { - i_warning("director(%s): PING response took %d secs to receive " + e_warning(conn->dir->event, + "director(%s): PING response took %d secs to receive " "(send buffer was %ju bytes)", conn->name, diff_secs, send_buffer_size); } @@ -1909,7 +1915,8 @@ static bool director_cmd_pong(struct director_connection *conn, if (ping_msecs > DIRECTOR_CONNECTION_PINGPONG_WARN_MSECS) { string_t *extra = t_str_new(128); director_ping_append_extra(conn, extra, sent_time, send_buffer_size); - i_warning("director(%s): PONG response took %u.%03u secs (%s)", + e_warning(conn->dir->event, + "director(%s): PONG response took %u.%03u secs (%s)", conn->name, ping_msecs/1000, ping_msecs%1000, str_c(extra)); } @@ -1982,7 +1989,8 @@ director_connection_handle_cmd(struct director_connection *conn, if (strcmp(cmd, "CONNECT") == 0) return director_cmd_connect(conn, args); if (strcmp(cmd, "QUIT") == 0) { - i_warning("Director %s disconnected us with reason: %s", + e_warning(conn->dir->event, + "Director %s disconnected us with reason: %s", conn->name, t_strarray_join(args, " ")); return FALSE; } @@ -2024,7 +2032,8 @@ director_connection_log_disconnect(struct director_connection *conn, int err, i_assert(conn->connected); if (conn->connect_request_to != NULL) { - i_warning("Director %s tried to connect to us, " + e_warning(conn->dir->event, + "Director %s tried to connect to us, " "should use %s instead", conn->name, conn->connect_request_to->name); return; @@ -2317,7 +2326,7 @@ director_connection_init_in(struct director *dir, int fd, conn->to_ping = timeout_add(DIRECTOR_CONNECTION_ME_TIMEOUT_MSECS, director_connection_init_timeout, conn); - i_info("Incoming connection from director %s", conn->name); + e_info(dir->event, "Incoming connection from director %s", conn->name); director_connection_send_handshake(conn); return conn; } diff --git a/src/director/director-request.c b/src/director/director-request.c index 25854b736f..af41f7f33e 100644 --- a/src/director/director-request.c +++ b/src/director/director-request.c @@ -169,10 +169,11 @@ void director_request(struct director *dir, const char *username, static void ring_noconn_warning(struct director *dir) { if (!dir->ring_handshaked) { - i_warning("Delaying all requests " + e_warning(dir->event, "Delaying all requests " "until all directors have connected"); } else { - i_warning("Delaying new user requests until ring is synced"); + e_warning(dir->event, + "Delaying new user requests until ring is synced"); } dir->ring_handshake_warning_sent = TRUE; timeout_remove(&dir->to_handshake_warning); diff --git a/src/director/director.c b/src/director/director.c index 44947bc724..8ac0f60705 100644 --- a/src/director/director.c +++ b/src/director/director.c @@ -143,7 +143,7 @@ director_log_connect(struct director *dir, struct director_host *host, str_printfa(str, ", last protocol failure %ds ago", (int)(ioloop_time - host->last_protocol_failure)); } - i_info("Connecting to %s:%u (as %s%s): %s", + e_info(dir->event, "Connecting to %s:%u (as %s%s): %s", host->ip_str, host->port, net_ip2addr(&dir->self_ip), str_c(str), reason); } @@ -262,13 +262,15 @@ void director_connect(struct director *dir, const char *reason) /* we're the only one */ if (count > 1) { - i_warning("director: Couldn't connect to right side, " + e_warning(dir->event, + "director: Couldn't connect to right side, " "we must be the only director left"); } if (dir->left != NULL) { /* since we couldn't connect to it, it must have failed recently */ - i_warning("director: Assuming %s is dead, disconnecting", + e_warning(dir->event, + "director: Assuming %s is dead, disconnecting", director_connection_get_name(dir->left)); director_connection_deinit(&dir->left, "This connection is dead?"); @@ -286,7 +288,8 @@ void director_set_ring_handshaked(struct director *dir) timeout_remove(&dir->to_handshake_warning); if (dir->ring_handshake_warning_sent) { - i_warning("Directors have been connected, " + e_warning(dir->event, + "Directors have been connected, " "continuing delayed requests"); dir->ring_handshake_warning_sent = FALSE; } @@ -325,7 +328,8 @@ void director_set_ring_synced(struct director *dir) timeout_remove(&dir->to_handshake_warning); if (dir->ring_handshake_warning_sent) { - i_warning("Ring is synced, continuing delayed requests " + e_warning(dir->event, + "Ring is synced, continuing delayed requests " "(syncing took %d secs, hosts_hash=%u)", (int)(ioloop_time - dir->ring_last_sync_time), mail_hosts_hash(dir->mail_hosts)); @@ -412,7 +416,8 @@ bool director_resend_sync(struct director *dir) hanging due to some bug. */ if (dir->to_reconnect == NULL && !director_has_any_outgoing_connections(dir)) { - i_warning("Right side connection is unexpectedly lost, reconnecting"); + e_warning(dir->event, + "Right side connection is unexpectedly lost, reconnecting"); director_connect(dir, "Right side connection lost"); } } else if (dir->left != NULL) { @@ -522,7 +527,8 @@ void director_notify_ring_added(struct director_host *added_host, const char *cmd; if (log) { - i_info("Adding director %s to ring (requested by %s)", + e_info(added_host->dir->event, + "Adding director %s to ring (requested by %s)", added_host->name, src->name); } @@ -559,7 +565,7 @@ void director_ring_remove(struct director_host *removed_host, unsigned int i, count; const char *cmd; - i_info("Removing director %s from ring (requested by %s)", + e_info(dir->event, "Removing director %s from ring (requested by %s)", removed_host->name, src->name); if (removed_host->self && !src->self) { diff --git a/src/director/doveadm-connection.c b/src/director/doveadm-connection.c index 4a8ca51e1e..ab3e9cb01a 100644 --- a/src/director/doveadm-connection.c +++ b/src/director/doveadm-connection.c @@ -488,7 +488,8 @@ doveadm_cmd_host_flush_all(struct doveadm_connection *conn) director_flush_host(conn->dir, conn->dir->self_host, NULL, *hostp); } - i_warning("Flushed all backend hosts with %u users. This is an unsafe " + e_warning(conn->dir->event, + "Flushed all backend hosts with %u users. This is an unsafe " "operation and may cause the same users to end up in multiple backends.", total_user_count); o_stream_nsend(conn->output, "OK\n", 3); @@ -576,7 +577,8 @@ director_host_reset_users(struct director_reset_cmd *cmd, } if (user == NULL) { int msecs = timeval_diff_msecs(&ioloop_timeval, &cmd->start_time); - i_info("Moved %u users in %u hosts in %u.%03u secs (max parallel=%u)", + e_info(dir->event, + "Moved %u users in %u hosts in %u.%03u secs (max parallel=%u)", cmd->reset_count, cmd->hosts_count - cmd->host_start_idx, msecs / 1000, msecs % 1000, cmd->max_moving_users); director_iterate_users_deinit(&cmd->iter); diff --git a/src/director/mail-host.c b/src/director/mail-host.c index 45176526fc..5d0d4a1de3 100644 --- a/src/director/mail-host.c +++ b/src/director/mail-host.c @@ -5,6 +5,7 @@ #include "bsearch-insert-pos.h" #include "crc32.h" #include "md5.h" +#include "director.h" #include "user-directory.h" #include "mail-host.h" @@ -338,7 +339,7 @@ void mail_host_set_down(struct mail_host *host, bool down, { if (host->down != down) { const char *updown = down ? "down" : "up"; - i_info("%sHost %s changed %s " + e_info(host->list->dir->event, "%sHost %s changed %s " "(vhost_count=%u last_updown_change=%ld)", log_prefix, host->ip_str, updown, host->vhost_count, (long)host->last_updown_change); @@ -352,7 +353,8 @@ void mail_host_set_down(struct mail_host *host, bool down, void mail_host_set_vhost_count(struct mail_host *host, unsigned int vhost_count, const char *log_prefix) { - i_info("%sHost %s vhost count changed from %u to %u", + e_info(host->list->dir->event, + "%sHost %s vhost count changed from %u to %u", log_prefix, host->ip_str, host->vhost_count, vhost_count); diff --git a/src/director/main.c b/src/director/main.c index 640f005182..36fce048da 100644 --- a/src/director/main.c +++ b/src/director/main.c @@ -164,7 +164,8 @@ static int director_client_connected(int fd, const struct ip_addr *ip) host = director_host_lookup_ip(director, ip); if (host == NULL || host->removed) { - i_warning("Connection from %s: Server not listed in " + e_warning(director->event, + "Connection from %s: Server not listed in " "director_servers, dropping", net_ip2addr(ip)); return -1; } diff --git a/src/director/notify-connection.c b/src/director/notify-connection.c index 2528eb9836..0a2b308f55 100644 --- a/src/director/notify-connection.c +++ b/src/director/notify-connection.c @@ -39,7 +39,8 @@ static void notify_update_user(struct director *dir, struct mail_tag *tag, diff = ioloop_time - user->timestamp; if (diff >= (int)dir->set->director_user_expire) { - i_warning("notify: User %s refreshed too late (%d secs)", + e_warning(dir->event, + "notify: User %s refreshed too late (%d secs)", username, diff); } user_directory_refresh(tag->users, user); diff --git a/src/director/user-directory.c b/src/director/user-directory.c index 6288a4818e..9a4244664b 100644 --- a/src/director/user-directory.c +++ b/src/director/user-directory.c @@ -6,6 +6,7 @@ #include "hash.h" #include "llist.h" #include "mail-host.h" +#include "director.h" /* n% of timeout_secs */ #define USER_NEAR_EXPIRING_PERCENTAGE 10 @@ -94,7 +95,8 @@ static bool user_directory_user_has_connections(struct user_directory *dir, return TRUE; } - i_warning("User %u weakness appears to be stuck, removing it", + e_warning(dir->director->event, + "User %u weakness appears to be stuck, removing it", user->username_hash); } return FALSE;