dovecot-2.2: lib-imap-urlauth: Fixed pending_request counter dif...

dovecot at dovecot.org dovecot at dovecot.org
Thu May 30 18:05:20 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/ec5d1686852c
changeset: 16422:ec5d1686852c
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu May 30 18:04:10 2013 +0300
description:
lib-imap-urlauth: Fixed pending_request counter difference between locally and remotely fetched URLAUTHs.

diffstat:

 src/lib-imap-urlauth/imap-urlauth-fetch.c |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (105 lines):

diff -r 8f09509323cd -r ec5d1686852c src/lib-imap-urlauth/imap-urlauth-fetch.c
--- a/src/lib-imap-urlauth/imap-urlauth-fetch.c	Thu May 30 18:03:53 2013 +0300
+++ b/src/lib-imap-urlauth/imap-urlauth-fetch.c	Thu May 30 18:04:10 2013 +0300
@@ -121,15 +121,15 @@
 	i_assert(ufetch->refcount > 0);
 
 	*_ufetch = NULL;
-	if (ufetch->refcount-1 > 0)
+	if (--ufetch->refcount > 0)
 		return;
 
+	ufetch->refcount++;
 	imap_urlauth_fetch_abort(ufetch);
-
 	ufetch->refcount--;
 	i_assert(ufetch->refcount == 0);
 
-	/* dont leave the connection in limbo; make sure resume is called */
+	/* dont leave the connection in limbo; make sure continue is called */
 	if (ufetch->waiting_service)
 		imap_urlauth_connection_continue(ufetch->uctx->conn);
 	i_free(ufetch);
@@ -161,10 +161,12 @@
 				       ufetch->context);
 	} T_END;
 
-	if (ret == 0)
+	if (ret == 0) {
 		ufetch->waiting_local = TRUE;
-	else if (ret < 0)
+		ufetch->pending_requests++;
+	} else if (ret < 0) {
 		imap_urlauth_fetch_fail(ufetch);
+	}
 }
 
 static void
@@ -251,10 +253,11 @@
 		}
 	}
 
+	ufetch->pending_requests--;
+
 	if (!success && ret < 0) {
 		if (mpurl != NULL)
 			imap_msgpart_url_free(&mpurl);
-		ufetch->pending_requests--;
 		(void)ufetch->callback(NULL, TRUE, ufetch->context);
 		imap_urlauth_fetch_fail(ufetch);
 		return;
@@ -271,13 +274,13 @@
 	reply.size = mpresult.size;
 	reply.input = mpresult.input;
 
-	ret = ufetch->callback(&reply, ufetch->pending_requests == 1,
+	ret = ufetch->callback(&reply, ufetch->pending_requests == 0,
 			       ufetch->context);
 	if (ret == 0) {
 		ufetch->local_url = mpurl;
 		ufetch->waiting_local = TRUE;
+		ufetch->pending_requests++;
 	} else {
-		ufetch->pending_requests--;
 
 		if (mpurl != NULL)
 			imap_msgpart_url_free(&mpurl);
@@ -328,6 +331,7 @@
 		ufetch->failed = TRUE;
 	} else if (ret == 0) {
 		ufetch->waiting_service = TRUE;
+		ufetch->pending_requests++;
 	}
 	
 	imap_urlauth_fetch_unref(&ufetch);
@@ -416,8 +420,13 @@
 	if (ufetch->failed)
 		return FALSE;
 
-	if (!ufetch->waiting_local && !ufetch->waiting_service)
+	if (!ufetch->waiting_local && !ufetch->waiting_service) {
+		/* not currently waiting for anything */
 		return ufetch->pending_requests > 0;
+	}
+
+	/* we finished a request */
+	ufetch->pending_requests--;
 
 	if (!ufetch->waiting_local) {
 		/* not waiting for local request handling */
@@ -428,7 +437,6 @@
 
 	/* finished local request */
 	if (ufetch->local_url != NULL) {
-		ufetch->pending_requests--;
 		imap_msgpart_url_free(&ufetch->local_url);
 	}
 	ufetch->waiting_local = FALSE;
@@ -468,6 +476,7 @@
 
 		if (ret == 0) {
 			ufetch->waiting_service = TRUE;
+			ufetch->pending_requests++;
 			return TRUE;
 		}
 	}


More information about the dovecot-cvs mailing list