--- httpbl.module	2010-04-18 16:43:32.000000000 +0100
+++ httpbl.module.patched	2011-02-16 16:03:51.000000000 +0000
@@ -654,8 +654,10 @@
 function _httpbl_cache_set($ip, $status, $offset = 0) {
   // DELETE and then INSERT leads to race conditions [#723358].
   // INSERT IGNORE could work as well, but neither have PostgreSQL alternatives.
-  // db_query("DELETE FROM {httpbl} WHERE hostname = '%s'", $ip);
-  db_query("REPLACE {httpbl} (hostname, status, expire) VALUES ('%s', %d, %d)", $ip, $status, time() + $offset);
+  db_lock_table('httpbl');  
+  db_query("DELETE FROM {httpbl} WHERE hostname = '%s'", $ip);
+  db_query("INSERT INTO {httpbl} (hostname, status, expire) VALUES ('%s', %d, %d)", $ip, $status, time() + $offset);
+  db_unlock_tables();
 
   if ($status == HTTPBL_LIST_BLACK && variable_get('httpbl_cache', HTTPBL_CACHE_DBDRUPAL)) {
     db_query("INSERT INTO {access} (mask, type, status) VALUES ('%s', '%s', %d)", $ip, 'host', 0);
@@ -707,4 +709,4 @@
   else {
     return $base_url . $script .'?q='. $path;
   }
-}
\ No newline at end of file
+}
