dovecot-2.2: lib-imap-urlauth: Made sure callbacks from URLAUTH ...

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/3ee64234a125
changeset: 16419:3ee64234a125
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu May 30 18:03:38 2013 +0300
description:
lib-imap-urlauth: Made sure callbacks from URLAUTH service connection are executed only once.

diffstat:

 src/lib-imap-urlauth/imap-urlauth-connection.c |  38 ++++++++++++++++---------
 1 files changed, 24 insertions(+), 14 deletions(-)

diffs (84 lines):

diff -r 4d711ec26847 -r 3ee64234a125 src/lib-imap-urlauth/imap-urlauth-connection.c
--- a/src/lib-imap-urlauth/imap-urlauth-connection.c	Thu May 30 17:45:27 2013 +0300
+++ b/src/lib-imap-urlauth/imap-urlauth-connection.c	Thu May 30 18:03:38 2013 +0300
@@ -320,9 +320,13 @@
 void imap_urlauth_request_abort(struct imap_urlauth_connection *conn,
 				struct imap_urlauth_request *urlreq)
 {
-	if (urlreq->callback != NULL) {
+	imap_urlauth_request_callback_t *callback;
+
+	callback = urlreq->callback;
+	urlreq->callback = NULL;
+	if (callback != NULL) {
 		T_BEGIN {
-			urlreq->callback(NULL, urlreq->context);
+			callback(NULL, urlreq->context);
 		} T_END;
 	}
 
@@ -331,7 +335,6 @@
 	    conn->targets_head->requests_head == urlreq) {
 		/* cannot just drop pending request without breaking
 		   protocol state */
-		urlreq->callback = NULL;
 		return;
 	}
 	imap_urlauth_request_free(urlreq);
@@ -343,22 +346,26 @@
 			  const char *error)
 {
 	struct imap_urlauth_fetch_reply reply;
+	imap_urlauth_request_callback_t *callback;
 
-	memset(&reply, 0, sizeof(reply));
-	reply.url = urlreq->url;
-	reply.flags = urlreq->flags;
-	reply.succeeded = FALSE;
-	reply.error = error;
+	callback = urlreq->callback;
+	urlreq->callback = NULL;
+	if (callback != NULL) {
+		memset(&reply, 0, sizeof(reply));
+		reply.url = urlreq->url;
+		reply.flags = urlreq->flags;
+		reply.succeeded = FALSE;
+		reply.error = error;
 
-	if (urlreq->callback != NULL) T_BEGIN {
-		(void)urlreq->callback(&reply, urlreq->context);
-	} T_END;
+		T_BEGIN {
+			(void)callback(&reply, urlreq->context);
+		} T_END;
+	}
 
 	if (conn->state == IMAP_URLAUTH_STATE_REQUEST_PENDING &&
 	    conn->targets_head != NULL &&
 	    conn->targets_head->requests_head == urlreq) {
 		/* cannot just drop pending request without breaking protocol state */
-		urlreq->callback = NULL;
 		return;
 	}
 
@@ -617,6 +624,7 @@
 {
 	struct imap_urlauth_request *urlreq = conn->targets_head->requests_head;
 	struct imap_urlauth_fetch_reply reply;
+	imap_urlauth_request_callback_t *callback;
 	int ret;
 
 	i_assert(conn->reading_literal);
@@ -643,8 +651,10 @@
 	reply.succeeded = TRUE;
 
 	ret = 1;
-	if (urlreq->callback != NULL) T_BEGIN {
-		ret = urlreq->callback(&reply, urlreq->context);
+	callback = urlreq->callback;
+	urlreq->callback = NULL;
+	if (callback != NULL) T_BEGIN {
+		ret = callback(&reply, urlreq->context);
 	} T_END;
 
 	if (reply.input != NULL)


More information about the dovecot-cvs mailing list