Mercurial > noffle
comparison src/noffle.c @ 281:5eece4dfd945 noffle
[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors
and exiting, Log_gdbm_fatal() for the the same but specifically as
a GDBM error reporting function, and a new log debug level AUTH for
a forthcoming authentication mechanism.
* src/database.c,src/group.c: Provide new gdbm error function to all
gdbm opens.
* src/noffle.c: Add atexit() to always close databases on a program-
inspired exit.
* src/content.c,src/dynamicstring.c,src/fetchlist.c,src/filter.c,
src/itemlist.c,src/log.c,src/log.h,src/over.c,src/protocol.h,
src/request.c,src/util.c: Use Log_fatal where appropriate.
author | bears |
---|---|
date | Fri, 27 Dec 2002 21:48:25 +0000 |
parents | d6fedc09b052 |
children | c02c4eb95f95 |
comparison
equal
deleted
inserted
replaced
280:9c54bf672ca1 | 281:5eece4dfd945 |
---|---|
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 402 2002-11-10 11:30:40Z bears $ | 13 $Id: noffle.c 413 2002-12-27 21:48:25Z 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 |
611 } | 611 } |
612 | 612 |
613 static void | 613 static void |
614 closeNoffle( void ) | 614 closeNoffle( void ) |
615 { | 615 { |
616 if ( noffle.lockAtStartup ) | 616 if ( Lock_gotLock() ) |
617 Lock_closeDatabases(); | 617 Lock_closeDatabases(); |
618 Lock_syncDatabases(); | 618 Lock_syncDatabases(); |
619 } | 619 } |
620 | 620 |
621 static RETSIGTYPE | 621 static RETSIGTYPE |
728 else | 728 else |
729 { | 729 { |
730 f = fopen( argv[0], "r" ); | 730 f = fopen( argv[0], "r" ); |
731 if ( f == NULL ) | 731 if ( f == NULL ) |
732 { | 732 { |
733 Log_err( "Can't access %s (%s).", argv[0], strerror( errno ) ); | 733 fprintf( stderr, "Can't access %s (%s).", argv[0], strerror( errno ) ); |
734 return EXIT_FAILURE; | 734 return EXIT_FAILURE; |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 if ( ! initNoffle() ) | 738 if ( ! initNoffle() ) |
743 result = EXIT_FAILURE; | 743 result = EXIT_FAILURE; |
744 | 744 |
745 if ( f != stdin ) | 745 if ( f != stdin ) |
746 fclose( f ); | 746 fclose( f ); |
747 | 747 |
748 closeNoffle(); | |
749 return result; | 748 return result; |
750 } | 749 } |
751 | 750 |
752 static int | 751 static int |
753 getArgLetter(const char *arg) | 752 getArgLetter(const char *arg) |
802 int main ( int argc, char **argv ) | 801 int main ( int argc, char **argv ) |
803 { | 802 { |
804 int c, result; | 803 int c, result; |
805 const char *cmdname, *p; | 804 const char *cmdname, *p; |
806 | 805 |
806 /* Attempt to ensure databases are properly closed when we exit */ | |
807 atexit( closeNoffle ); | |
808 | |
807 signal( SIGSEGV, bugReport ); | 809 signal( SIGSEGV, bugReport ); |
808 signal( SIGABRT, logSignal ); | 810 signal( SIGABRT, logSignal ); |
809 signal( SIGFPE, logSignal ); | 811 signal( SIGFPE, logSignal ); |
810 signal( SIGILL, logSignal ); | 812 signal( SIGILL, logSignal ); |
811 signal( SIGINT, logSignal ); | 813 signal( SIGINT, logSignal ); |
1009 printf( "NNTP server NOFFLE, version %s.\n", Cfg_version() ); | 1011 printf( "NNTP server NOFFLE, version %s.\n", Cfg_version() ); |
1010 break; | 1012 break; |
1011 default: | 1013 default: |
1012 abort(); /* Never reached */ | 1014 abort(); /* Never reached */ |
1013 } | 1015 } |
1014 closeNoffle(); | |
1015 return result; | 1016 return result; |
1016 } | 1017 } |