diff src/noffle.c @ 165:8ea6b5ddc5a5 noffle

[svn] * src/lock.h,src/lock.c,src/noffle.c: Add lazy lock release. Only release the lock and close the databases if (a) another process signals us SIGUSR1 indicating it wants the lock, or (b) it is explicitly requested by a call to new function Lock_syncDatabases(). When waiting for the lock, SIGUSR1 the holding process every second. This is all an attempt to minimise the number of times we need to close and open the database. When (ha!) the database is replaced by something that can handle multiple simultaneous writers (with appropriate locking) this won't be necessary.
author bears
date Thu, 25 Jan 2001 13:38:31 +0000
parents 1c7303c71f66
children cf2274194d38
line wrap: on
line diff
--- a/src/noffle.c	Thu Jan 25 11:00:03 2001 +0000
+++ b/src/noffle.c	Thu Jan 25 13:38:31 2001 +0000
@@ -10,7 +10,7 @@
   received for some seconds (to allow multiple clients connect at the same
   time).
 
-  $Id: noffle.c 227 2000-10-26 21:21:13Z bears $
+  $Id: noffle.c 249 2001-01-25 13:38:31Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -598,6 +598,7 @@
 {
     if ( noffle.lockAtStartup )
       Lock_closeDatabases();
+    Lock_syncDatabases();
 }
 
 static RETSIGTYPE
@@ -605,6 +606,10 @@
 {
     Log_err( "Received SIGSEGV. Please submit a bug report" );
     signal( SIGSEGV, SIG_DFL );
+
+    /* Attempt to save database state before passing on sig. */
+    Lock_syncDatabases();
+    
     raise( sig );
 }
 
@@ -636,6 +641,10 @@
     else
         Log_inf( "Received signal %i (%s). Aborting.", sig, name );
     signal( sig, SIG_DFL );
+
+    /* Attempt to save database state before passing on sig. */
+    Lock_syncDatabases();
+    
     raise( sig );
 }