From 285f36d4baa2ae2a87f8c4596401f73f666bef7a Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Wed, 11 Aug 2010 16:55:11 +0200
Subject: [PATCH] Multiscript: fixed duplicate implicit keep caused by
 erroneous execution state update.

---
 src/lib-sieve/sieve.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/lib-sieve/sieve.c b/src/lib-sieve/sieve.c
index 9328ab15a..93e8bfb70 100644
--- a/src/lib-sieve/sieve.c
+++ b/src/lib-sieve/sieve.c
@@ -453,7 +453,6 @@ struct sieve_multiscript {
 
 	int status;
 	bool active;
-	bool ended;
 	bool keep;
 
 	struct ostream *teststream;
@@ -508,8 +507,6 @@ static void sieve_multiscript_test
 	} else {
 		if ( keep != NULL ) *keep = TRUE;
 	}
-		
-	mscript->active = ( mscript->active && *keep );
 
 	sieve_result_mark_executed(mscript->result);
 }
@@ -528,8 +525,6 @@ static void sieve_multiscript_execute
 		else
 			if ( keep != NULL ) *keep = TRUE;			
 	}
-	
-	mscript->active = ( mscript->active && *keep );
 }
 
 bool sieve_multiscript_run
@@ -553,7 +548,8 @@ bool sieve_multiscript_run
 		else
 			sieve_multiscript_execute(mscript, ehandler, &mscript->keep);
 
-		if ( final ) mscript->active = FALSE;
+		mscript->active =
+			( mscript->active && mscript->keep && !final && mscript->status > 0 );
 	}	
 
 	if ( mscript->status <= 0 )
-- 
GitLab