From e47dd69b09e4f8efb0ba55b7c3d70a864a534558 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 20 Oct 2016 16:14:36 +0300 Subject: [PATCH] director: Code cleanup - moved code to notify_update_user() --- src/director/notify-connection.c | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/director/notify-connection.c b/src/director/notify-connection.c index 76ecfd3aa5..05ba2ba40d 100644 --- a/src/director/notify-connection.c +++ b/src/director/notify-connection.c @@ -17,28 +17,34 @@ struct notify_connection { struct director *dir; }; -static void notify_connection_input(struct notify_connection *conn) +static void notify_update_user(struct director *dir, const char *username, + unsigned int username_hash) { struct user *user; + int diff; + + user = user_directory_lookup(dir->users, username_hash); + if (user == NULL) + return; + + diff = ioloop_time - user->timestamp; + if (diff >= (int)dir->set->director_user_expire) { + i_warning("notify: User %s refreshed too late (%d secs)", + username, diff); + } + user_directory_refresh(dir->users, user); + director_update_user(dir, dir->self_host, user); +} + +static void notify_connection_input(struct notify_connection *conn) +{ const char *line; unsigned int hash; - int diff; while ((line = i_stream_read_next_line(conn->input)) != NULL) { if (!user_directory_get_username_hash(conn->dir->users, line, &hash)) continue; - - user = user_directory_lookup(conn->dir->users, hash); - if (user != NULL) { - diff = ioloop_time - user->timestamp; - if (diff >= (int)conn->dir->set->director_user_expire) { - i_warning("notify: User %s refreshed too late " - "(%d secs)", line, diff); - } - user_directory_refresh(conn->dir->users, user); - director_update_user(conn->dir, conn->dir->self_host, - user); - } + notify_update_user(conn->dir, line, hash); } if (conn->input->eof) { i_error("notify: read() unexpectedly returned EOF"); -- 2.47.3