]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: Code cleanup - moved code to notify_update_user()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Thu, 20 Oct 2016 13:14:36 +0000 (16:14 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Wed, 9 Nov 2016 12:43:41 +0000 (14:43 +0200)
src/director/notify-connection.c

index c32a62231e27f8a17336a5de894dbc33b2037eb6..523cc79af90d6c973c134871df465761b1ca42e4 100644 (file)
@@ -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");