]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
director: If user's weak-flag appears to have gotten stuck, unset it.
authorTimo Sirainen <tss@iki.fi>
Mon, 22 Oct 2012 12:29:27 +0000 (15:29 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 22 Oct 2012 12:29:27 +0000 (15:29 +0300)
src/director/director-request.c
src/director/user-directory.c

index 9479583dcea6041029cf988eb5cd04929b78a802..04130f33f414e51ae958c602e1fe72a74595330e 100644 (file)
@@ -91,6 +91,13 @@ static void director_request_timeout(struct director *dir)
                                             request->username_hash);
                errormsg = director_request_get_timeout_error(request,
                                                              user, str);
+               if (user != NULL &&
+                   request->delay_reason == REQUEST_DELAY_WEAK) {
+                       /* weakness appears to have gotten stuck. this is a
+                          bug, but try to fix it for future requests by
+                          removing the weakness. */
+                       user->weak = FALSE;
+               }
 
                array_delete(&dir->pending_requests, 0, 1);
                T_BEGIN {
index 525de2a158b6fc696b7d988c214d3a7a442882ee..fa72279cb4bc767fc041ce9c535d2090c7611a85 100644 (file)
@@ -65,7 +65,22 @@ static bool user_directory_user_has_connections(struct user_directory *dir,
 {
        time_t expire_timestamp = user->timestamp + dir->timeout_secs;
 
-       return expire_timestamp >= ioloop_time;
+       if (expire_timestamp >= ioloop_time)
+               return TRUE;
+
+       if (user->kill_state != USER_KILL_STATE_NONE) {
+               /* don't free this user until the kill is finished */
+               return TRUE;
+       }
+
+       if (user->weak) {
+               if (expire_timestamp + USER_NEAR_EXPIRING_MAX >= ioloop_time)
+                       return TRUE;
+
+               i_warning("User %u weakness appears to be stuck, removing it",
+                         user->username_hash);
+       }
+       return FALSE;
 }
 
 static void user_directory_drop_expired(struct user_directory *dir)