dovecot-2.2-pigeonhole: lib-sieve: Added more debug output to bi...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Thu Jan 1 16:17:13 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/1bcac73bab61
changeset: 1983:1bcac73bab61
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu Jan 01 17:12:17 2015 +0100
description:
lib-sieve: Added more debug output to binary up-to-date checking.

diffstat:

 src/lib-sieve/sieve-binary.c                   |  24 +++++++++++++++++++++---
 src/lib-sieve/storage/file/sieve-file-script.c |  14 ++++++++++++--
 2 files changed, 33 insertions(+), 5 deletions(-)

diffs (82 lines):

diff -r b6c55ac6460d -r 1bcac73bab61 src/lib-sieve/sieve-binary.c
--- a/src/lib-sieve/sieve-binary.c	Tue Dec 30 23:01:04 2014 +0100
+++ b/src/lib-sieve/sieve-binary.c	Thu Jan 01 17:12:17 2015 +0100
@@ -315,22 +315,40 @@
 	struct sieve_binary_block *sblock;
 	sieve_size_t offset = 0;
 	unsigned int ext_count, i;
+	int ret;
 
 	i_assert(sbin->file != NULL);
 
 	sblock = sieve_binary_block_get(sbin, SBIN_SYSBLOCK_SCRIPT_DATA);
-	if ( sblock == NULL || sbin->script == NULL ||
-		sieve_script_binary_read_metadata(sbin->script, sblock, &offset) <= 0 )
+	if ( sblock == NULL || sbin->script == NULL )
 		return FALSE;
 
+	if ( (ret=sieve_script_binary_read_metadata
+		(sbin->script, sblock, &offset)) <= 0 ) {
+		if (ret < 0) {
+			sieve_sys_debug(sbin->svinst, "binary up-to-date: "
+				"failed to read script metadata from binary %s",
+				sbin->path);
+		} else {
+			sieve_sys_debug(sbin->svinst, "binary up-to-date: "
+				"script metadata indicates that binary %s is not up-to-date",
+				sbin->path);
+		}
+		return FALSE;
+	}
+
 	regs = array_get(&sbin->extensions, &ext_count);
 	for ( i = 0; i < ext_count; i++ ) {
 		const struct sieve_binary_extension *binext = regs[i]->binext;
 
 		if ( binext != NULL && binext->binary_up_to_date != NULL &&
 			!binext->binary_up_to_date
-				(regs[i]->extension, sbin, regs[i]->context, cpflags) )
+				(regs[i]->extension, sbin, regs[i]->context, cpflags) ) {
+			sieve_sys_debug(sbin->svinst, "binary up-to-date: "
+				"the %s extension indicates binary %s is not up-to-date",
+				sieve_extension_name(regs[i]->extension), sbin->path);
 			return FALSE;
+		}
 	}
 
 	return TRUE;
diff -r b6c55ac6460d -r 1bcac73bab61 src/lib-sieve/storage/file/sieve-file-script.c
--- a/src/lib-sieve/storage/file/sieve-file-script.c	Tue Dec 30 23:01:04 2014 +0100
+++ b/src/lib-sieve/storage/file/sieve-file-script.c	Thu Jan 01 17:12:17 2015 +0100
@@ -5,6 +5,7 @@
 #include "mempool.h"
 #include "abspath.h"
 #include "istream.h"
+#include "time-util.h"
 #include "eacces-error.h"
 
 #include "sieve-binary.h"
@@ -475,12 +476,21 @@
 	sieve_size_t *offset ATTR_UNUSED)
 {
 	struct sieve_file_script *fscript = (struct sieve_file_script *)script;
+	struct sieve_instance *svinst = script->storage->svinst;
 	struct sieve_binary *sbin = sieve_binary_block_get_binary(sblock);
-	time_t time = ( fscript->st.st_mtime > fscript->lnk_st.st_mtime ?
+	time_t bmtime = sieve_binary_mtime(sbin);
+	time_t smtime = ( fscript->st.st_mtime > fscript->lnk_st.st_mtime ?
 		fscript->st.st_mtime : fscript->lnk_st.st_mtime );
 
-	if ( sieve_binary_mtime(sbin) <= time )
+	if ( bmtime <= smtime ) {
+		if (svinst->debug) {
+			sieve_script_sys_debug(script,
+				"Sieve binary is not newer than the Sieve script (%s <= %s)",
+				t_strflocaltime("%Y-%m-%d %H:%M:%S", bmtime),
+				t_strflocaltime("%Y-%m-%d %H:%M:%S", smtime));
+		}
 		return 0;
+	}
 
 	return 1;
 }


More information about the dovecot-cvs mailing list