From 7bf427ca4bf12f0f00fd4dc7237d261a1c524e5d 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 | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/director/notify-connection.c b/src/director/notify-connection.c index c32a62231e..523cc79af9 100644 --- a/src/director/notify-connection.c +++ b/src/director/notify-connection.c @@ -17,26 +17,33 @@ 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) { hash = user_directory_get_username_hash(conn->dir->users, line); - 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