DISABLED: Far too complicated to fix a problem that can be solved by simply
always stopping Deadwood then deleting Deadwood's cache when making a 
configuration file change.

diff -ur deadwood-3.2.03/doc/internals/RR.Allocation deadwood-3.2.04/doc/internals/RR.Allocation
--- deadwood-3.2.03/doc/internals/RR.Allocation	2010-07-06 07:43:55.000000000 -0700
+++ deadwood-3.2.04/doc/internals/RR.Allocation	2013-02-21 18:02:01.000000000 -0800
@@ -10,3 +10,9 @@
 
 65395 (0xff73) is used for NS referrals
 
+65396 (0xff74) is used to store metadata in Deadwood's cache.  Right now,
+        the following keys are used:
+
+* The key "\x04TIME\x00\xff\x74" is used to store when the 
+  dwood3rc file was previously modified
+
diff -ur deadwood-3.2.03/src/DwHash.c deadwood-3.2.04/src/DwHash.c
--- deadwood-3.2.03/src/DwHash.c	2012-12-20 10:30:37.000000000 -0800
+++ deadwood-3.2.04/src/DwHash.c	2013-02-21 18:51:00.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2012 Sam Trenholme
+/* Copyright (c) 2007-2013 Sam Trenholme
  *
  * TERMS
  *
@@ -42,6 +42,10 @@
 /* Timestamp */
 extern int64_t the_time;
 
+/* Stat mtime information */
+extern struct stat mararc_st;
+time_t mararc_old_mtime;
+
 /* Functions for hashing DwStr objects, and using said hash to store
  * information in a table */
 
@@ -856,6 +860,18 @@
 
 }
 
+int dwh_put_stat_metadata(FILE *handle) {
+	int64_t t_stat_raw = 0;
+
+	t_stat_raw = (int64_t)(mararc_st.st_mtime);
+	dwh_put_int32(handle,8);
+	dwh_put_int64(handle,0x0454494D4500FF74LL); /* \x04TIME\x00\xff\x74 */
+	dwh_put_int32(handle,8);
+	dwh_put_int64(handle,t_stat_raw);
+	dwh_put_int64(handle,7); /* Bogus "expire" value */
+	return 1;
+}
+
 /* Write an entire hash (assosciated array) to a given file; 1 on
  * success; -1 on error.  This is a public function. */
 int dwh_write_hash(dw_hash *hash, char *filename) {
@@ -880,8 +896,12 @@
 
         /* Mark this file as a "Deadwood 2" file */
         dwh_put_int32(handle,0x00445733); /* '\0'DW3 */
-        /* Put a 32-bit number in which is 0; for possible future use */
-        dwh_put_int32(handle,0);
+        /* Put a 32-bit number in which was 0 in older DW releases */
+	/* The number "0x7f740000" means "first cache element is meta-data
+         * not to be put in to the cache.  Values between 0x7f740000 and
+         * 0x7f7400ff allow up to 256 meta-elements */
+        dwh_put_int32(handle,0x7f740000);
+	dwh_put_stat_metadata(handle);
 
         /* We go backwards so, when reading the hash, the least important
          * elements are put in first, since each new element put in the
@@ -1027,6 +1047,10 @@
         out->key = dwh_get_dwstr(handle);
         out->value = dwh_get_dwstr(handle);
         out->expire = dwh_get_int64(handle);
+
+	/* Coding style: Always fully initialize a structure */
+	out->fila = 0; out->next = 0; out->prev = 0; out->immutable = 0;
+
         if(out->key == 0 || out->value == 0 || out->expire < 2) {
                 goto catch_dwh_get_hash_element;
         }
@@ -1051,6 +1075,27 @@
         return 0;
 }
 
+int dwh_read_stat_metadata(FILE *handle) {
+	int64_t t_stat_raw = 0;
+
+	if(dwh_get_int32(handle) != 8) {
+		return 0;
+	}	
+	if(dwh_get_int64(handle) != 0x0454494D4500FF74LL) { 
+		/* Must be bogus "\x04TIME\x00\xff\x74" hash key */
+		return 0;
+	}
+	if(dwh_get_int32(handle) != 8) {
+		return 0;
+	}	
+	t_stat_raw = dwh_get_int64(handle);	
+	mararc_old_mtime = (time_t)t_stat_raw;
+	if(dwh_get_int64(handle) != 7) { /* Bogus "expire" value */
+		return 0;
+	}
+	return 1;
+}
+
 /* Read a hash from a file, and return the hash read from the file
  * as a hash pointer to the calling function */
 dw_hash *dwh_read_hash(char *filename) {
@@ -1058,6 +1103,8 @@
         dw_hash *new = 0;
         dw_element *ele = 0;
         int32_t max = 0, counter = 0;
+	int32_t meta_num = 0;
+	int elements = 0;
 
         if(filename == 0) {
                 return 0;
@@ -1077,7 +1124,21 @@
                 return 0;
         }
 
-        dwh_get_int32(handle); /* Read and ignore 32-bit value */
+        /* Read (and usually ignore) 32-bit value */
+	meta_num = dwh_get_int32(handle);
+        if((meta_num & 0xffffff00) == 0x7f740000) { 
+		elements = (meta_num & 0xff);
+		if(elements < 0) { elements = 0; }
+		/* First cache element: Stat metadata */
+		if(dwh_read_stat_metadata(handle) == 0) { return 0; }
+		/* This code (which has a slight one-time memory leak),
+                 * allows Deadwood 3.2.04 to read cache files generated
+                 * by future Deadwood releases */
+		while(elements > 0) { 
+			ele = dwh_get_hash_element(handle);
+			elements--;
+		}	
+	}
 
         /* Maximum number of elements in hash */
         if(cache_size > 32 && cache_size < 16777218) {
diff -ur deadwood-3.2.03/src/DwSys.c deadwood-3.2.04/src/DwSys.c
--- deadwood-3.2.03/src/DwSys.c	2012-12-20 10:30:37.000000000 -0800
+++ deadwood-3.2.04/src/DwSys.c	2013-02-21 18:33:25.000000000 -0800
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2012 Sam Trenholme
+/* Copyright (c) 2007-2013 Sam Trenholme
  *
  * TERMS
  *
@@ -40,6 +40,7 @@
 /* Whether to read the cache file */
 int do_read_cache = 1;
 struct stat mararc_st;
+extern time_t mararc_old_mtime;
 
 /* Mararc parameters that are set in DwMararc.c */
 extern dw_str *key_s[];
