comparison 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
comparison
equal deleted inserted replaced
164:94f2e5607772 165:8ea6b5ddc5a5
8 not as server. If noffle runs as server, locking is performed while 8 not as server. If noffle runs as server, locking is performed while
9 executing NNTP commands, but temporarily released if no new command is 9 executing NNTP commands, but temporarily released if no new command is
10 received for some seconds (to allow multiple clients connect at the same 10 received for some seconds (to allow multiple clients connect at the same
11 time). 11 time).
12 12
13 $Id: noffle.c 227 2000-10-26 21:21:13Z bears $ 13 $Id: noffle.c 249 2001-01-25 13:38:31Z bears $
14 */ 14 */
15 15
16 #if HAVE_CONFIG_H 16 #if HAVE_CONFIG_H
17 #include <config.h> 17 #include <config.h>
18 #endif 18 #endif
596 static void 596 static void
597 closeNoffle( void ) 597 closeNoffle( void )
598 { 598 {
599 if ( noffle.lockAtStartup ) 599 if ( noffle.lockAtStartup )
600 Lock_closeDatabases(); 600 Lock_closeDatabases();
601 Lock_syncDatabases();
601 } 602 }
602 603
603 static RETSIGTYPE 604 static RETSIGTYPE
604 bugReport( int sig ) 605 bugReport( int sig )
605 { 606 {
606 Log_err( "Received SIGSEGV. Please submit a bug report" ); 607 Log_err( "Received SIGSEGV. Please submit a bug report" );
607 signal( SIGSEGV, SIG_DFL ); 608 signal( SIGSEGV, SIG_DFL );
609
610 /* Attempt to save database state before passing on sig. */
611 Lock_syncDatabases();
612
608 raise( sig ); 613 raise( sig );
609 } 614 }
610 615
611 static RETSIGTYPE 616 static RETSIGTYPE
612 logSignal( int sig ) 617 logSignal( int sig )
634 if ( err ) 639 if ( err )
635 Log_err( "Received signal %i (%s). Aborting.", sig, name ); 640 Log_err( "Received signal %i (%s). Aborting.", sig, name );
636 else 641 else
637 Log_inf( "Received signal %i (%s). Aborting.", sig, name ); 642 Log_inf( "Received signal %i (%s). Aborting.", sig, name );
638 signal( sig, SIG_DFL ); 643 signal( sig, SIG_DFL );
644
645 /* Attempt to save database state before passing on sig. */
646 Lock_syncDatabases();
647
639 raise( sig ); 648 raise( sig );
640 } 649 }
641 650
642 static void 651 static void
643 printInewsUsage( void ) 652 printInewsUsage( void )