[master] 215a1c8 Ensure that smp_object always are a multiple of 8 bytes.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jul 28 14:15:31 CEST 2014


commit 215a1c887d70f0fe4b2dc26f2e8a75d9560b8ce5
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 28 12:14:55 2014 +0000

    Ensure that smp_object always are a multiple of 8 bytes.

diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index 7d423e1..68f969d 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -145,6 +145,7 @@ struct smp_segptr {
 struct smp_object {
 	uint8_t			hash[32];	/* really: DIGEST_LEN */
 	struct exp		exp;
+	uint32_t		__filler__;	/* -> align/8 on 32bit */
 	double			ban;
 	uint64_t		ptr;		/* rel to silo */
 };
diff --git a/bin/varnishd/storage/storage_persistent_mgt.c b/bin/varnishd/storage/storage_persistent_mgt.c
index f99a6ae..33f41e0 100644
--- a/bin/varnishd/storage/storage_persistent_mgt.c
+++ b/bin/varnishd/storage/storage_persistent_mgt.c
@@ -136,6 +136,10 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av)
 	ASSERT_MGT();
 
 	AZ(av[ac]);
+
+	/* Necessary alignment. See also smp_object::__filler__ */
+	assert(sizeof(struct smp_object) % 8 == 0);
+
 #define SIZOF(foo)       fprintf(stderr, \
     "sizeof(%s) = %zu = 0x%zx\n", #foo, sizeof(foo), sizeof(foo));
 	SIZOF(struct smp_ident);



More information about the varnish-commit mailing list