--- wp-cache-config-sample.php	2008-09-17 17:37:02.000000000 -0700
+++ wp-cache-config-sample.php	2008-09-19 16:03:11.000000000 -0700
@@ -11,7 +11,6 @@
 $cache_enabled = false;
 $super_cache_enabled = false;
 $cache_max_time = 3600; //in seconds
-//$use_flock = true; // Set it true or false if you know what to use
 $super_cache_max_time = 21600; // in seconds
 $cache_path = WP_CONTENT_DIR . '/cache/';
 $file_prefix = 'wp-cache-';
@@ -43,8 +42,12 @@
 $cache_rejected_uri = array('wp-.*.php', 'index.php');
 $cache_rejected_user_agent = array ( 0 => 'bot', 1 => 'ia_archive', 2 => 'slurp', 3 => 'crawl', 4 => 'spider');
 
-// Just modify it if you have conflicts with semaphores
-$sem_id = 5419;
+// This section controls how locking is handled. In most cases, you can leave
+// both lines commented out and a unique semaphore ID will be used. To use
+// flock() instead, uncomment the first line. To use a specific semaphore ID,
+// uncomment the second line and optionally change the number.
+//$use_flock = true;
+//$sem_id = 5419;
 
 if ( '/' != substr($cache_path, -1)) {
 	$cache_path .= '/';
--- wp-cache-phase2.php	2008-09-17 17:37:02.000000000 -0700
+++ wp-cache-phase2.php	2008-09-19 15:47:27.000000000 -0700
@@ -96,8 +96,15 @@
 	$mutex = false;
 	if ($use_flock) 
 		$mutex = @fopen($cache_path . $mutex_filename, 'w');
-	else
+	else {
+		if (empty($sem_id)) {
+			// No explicit semaphore ID is set. Calculate one that's likely
+			// to be unique abnd constant for this WordPress installation,
+			// based on the path. End up with a positive integer < 2^31.
+			$sem_id = sprintf("%u", crc32($cache_path) & 0x7fffffff);
+		}
 		$mutex = @sem_get($sem_id, 1, 0644 | IPC_CREAT, 1);
+	}
 }
 
 function wp_cache_writers_entry() {
