#include "array.h"
#include "str.h"
#include "strescape.h"
+#include "log-throttle.h"
#include "ipc-client.h"
#include "user-directory.h"
#include "mail-host.h"
bool director_debug;
+static struct log_throttle *user_move_throttle;
+static struct log_throttle *user_kill_fail_throttle;
+
+static const struct log_throttle_settings director_log_throttle_settings = {
+ .throttle_at_max_per_interval = 100,
+ .unthrottle_at_max_per_interval = 2,
+};
+
static bool director_is_self_ip_set(struct director *dir)
{
struct ip_addr ip;
}
}
+static void director_user_kill_fail_throttled(unsigned int new_events_count,
+ void *context ATTR_UNUSED)
+{
+ i_error("Failed to kill %u users' connections", new_events_count);
+}
+
static void director_kill_user_callback(enum ipc_client_cmd_state state,
const char *data, void *context)
{
case IPC_CLIENT_CMD_STATE_OK:
break;
case IPC_CLIENT_CMD_STATE_ERROR:
- i_error("Failed to kill user %u connections: %s",
- ctx->username_hash, data);
+ if (log_throttle_accept(user_kill_fail_throttle)) {
+ i_error("Failed to kill user %u connections: %s",
+ ctx->username_hash, data);
+ }
/* we can't really do anything but continue anyway */
break;
}
i_free(ctx);
}
+static void director_user_move_throttled(unsigned int new_events_count,
+ void *context ATTR_UNUSED)
+{
+ i_error("%u users' move timed out, their state may now be inconsistent",
+ new_events_count);
+}
+
static void director_user_move_timeout(struct user *user)
{
i_assert(user->kill_state != USER_KILL_STATE_DELAY);
- i_error("Finishing user %u move timed out, "
- "its state may now be inconsistent", user->username_hash);
+ if (log_throttle_accept(user_move_throttle)) {
+ i_error("Finishing user %u move timed out, "
+ "its state may now be inconsistent", user->username_hash);
+ }
user->kill_state = USER_KILL_STATE_NONE;
timeout_remove(&user->to_move);
} T_END;
va_end(args);
}
+
+void directors_init(void)
+{
+ user_move_throttle =
+ log_throttle_init(&director_log_throttle_settings,
+ director_user_move_throttled, NULL);
+ user_kill_fail_throttle =
+ log_throttle_init(&director_log_throttle_settings,
+ director_user_kill_fail_throttled, NULL);
+}
+
+void directors_deinit(void)
+{
+ log_throttle_deinit(&user_move_throttle);
+ log_throttle_deinit(&user_kill_fail_throttle);
+}
"(for standalone keep director_servers empty)");
}
+ directors_init();
director = director_init(set, &listen_ip, listen_port,
director_state_changed);
director_host_add_from_string(director, set->director_servers);
if (notify_conn != NULL)
notify_connection_deinit(¬ify_conn);
director_deinit(&director);
+ directors_deinit();
doveadm_connections_deinit();
login_connections_deinit();
auth_connections_deinit();