r3822 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Feb 23 16:58:39 CET 2009


Author: phk
Date: 2009-02-23 16:58:39 +0100 (Mon, 23 Feb 2009)
New Revision: 3822

Modified:
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Explain what functions do.



Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-02-23 15:48:33 UTC (rev 3821)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-02-23 15:58:39 UTC (rev 3822)
@@ -83,7 +83,9 @@
 	VTAILQ_HEAD(, smp_seg)	segments;
 };
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Write a sha256hash after a sequence of bytes.
+ */
 
 static void
 smp_make_hash(void *ptr, off_t len)
@@ -98,7 +100,9 @@
 	SHA256_Final(dest, &c);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Check that a sequence of bytes matches the SHA256 stored behind it.
+ */
 
 static int
 smp_check_hash(void *ptr, off_t len)
@@ -115,7 +119,9 @@
 	return(memcmp(sign, dest, sizeof sign));
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Create or write a signature block covering a sequence of bytes.
+ */
 
 static void
 smp_create_sign(const struct smp_sc *sc, uint64_t adr, uint64_t len, const char *id)
@@ -136,7 +142,9 @@
     adr, len, id);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Force a write of a signature block to the backing store.
+ */
 
 static void
 smp_sync_sign(const struct smp_sc *sc, uint64_t adr, uint64_t len)
@@ -149,7 +157,9 @@
 fprintf(stderr, "SyncSign(%jx, %jx)\n", adr, len);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Check a signature block and return zero if OK.
+ */
 
 static int
 smp_check_sign(const struct smp_sc *sc, uint64_t adr, const char *id)
@@ -169,7 +179,9 @@
 	return (smp_check_hash(ss, sizeof *ss + ss->length));
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Open a signature block, and return zero if it is valid.
+ */
 
 static int
 smp_open_sign(const struct smp_sc *sc, uint64_t adr, void **ptr, uint64_t *len, const char *id)
@@ -189,7 +201,11 @@
 	return (i);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Initialize a Silo with a valid but empty structure.
+ *
+ * XXX: more intelligent sizing of things.
+ */
 
 static void
 smp_newsilo(struct smp_sc *sc)
@@ -211,7 +227,6 @@
 	si->mediasize = sc->mediasize;
 	si->granularity = sc->granularity;
 
-	/* XXX: intelligent sizing of things */
 	si->stuff[SMP_BAN1_STUFF] = sc->granularity;
 	si->stuff[SMP_BAN2_STUFF] = si->stuff[SMP_BAN1_STUFF] + 1024*1024;
 	si->stuff[SMP_SEG1_STUFF] = si->stuff[SMP_BAN2_STUFF] + 1024*1024;
@@ -226,7 +241,9 @@
 	smp_make_hash(si, sizeof *si);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Check if a silo is valid.
+ */
 
 static int
 smp_valid_silo(struct smp_sc *sc)
@@ -277,7 +294,9 @@
 	return (0);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Set up persistent storage silo in the master process.
+ */
 
 static void
 smp_init(struct stevedore *parent, int ac, char * const *av)
@@ -383,7 +402,9 @@
 	smp_save_seg(sc, sc->ident->stuff[SMP_SEG2_STUFF], "SEG 2");
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Attempt to open and read in a segment list
+ */
 
 static int
 smp_open_segs(struct smp_sc *sc, int stuff, const char *id)
@@ -413,10 +434,15 @@
 		VTAILQ_INSERT_TAIL(&sc->segments, sg, list);
 fprintf(stderr, "MK SEG %jx %jx\n", sg->offset, sg->length);
 	}
+
+	/* XXX: sanity check pointer+length for validity and non-overlap */
+
 	return (0);
 }
 
-/*--------------------------------------------------------------------*/
+/*--------------------------------------------------------------------
+ * Open a silo in the worker process
+ */
 
 static void
 smp_open(const struct stevedore *st)
@@ -433,7 +459,7 @@
 	/* XXX: read in bans */
 
 	/*
-	 * We attempt seg1 first, and if that fails, take seg2
+	 * We attempt seg1 first, and if that fails, try seg2
 	 */
 	if (smp_open_segs(sc, SMP_SEG1_STUFF, "SEG 1"))
 		AZ(smp_open_segs(sc, SMP_SEG2_STUFF, "SEG 2"));



More information about the varnish-commit mailing list