comparison src/database.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 16dad3488e9d
children baa6408d1bbc
comparison
equal deleted inserted replaced
280:9c54bf672ca1 281:5eece4dfd945
1 /* 1 /*
2 database.c 2 database.c
3 3
4 $Id: database.c 408 2002-11-10 18:31:25Z bears $ 4 $Id: database.c 413 2002-12-27 21:48:25Z bears $
5 5
6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was 6 Uses GNU gdbm library. Using Berkeley db (included in libc6) was
7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs 7 cumbersome. It is based on Berkeley db 1.85, which has severe bugs
8 (e.g. it is not recommended to delete or overwrite entries with 8 (e.g. it is not recommended to delete or overwrite entries with
9 overflow pages). 9 overflow pages).
77 77
78 ASSERT( db.dbf == NULL ); 78 ASSERT( db.dbf == NULL );
79 snprintf( name, MAXCHAR, ARTICLE_FILENAME_FMT, Cfg_spoolDir() ); 79 snprintf( name, MAXCHAR, ARTICLE_FILENAME_FMT, Cfg_spoolDir() );
80 flags = GDBM_WRCREAT | GDBM_FAST; 80 flags = GDBM_WRCREAT | GDBM_FAST;
81 81
82 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) 82 if ( ! ( db.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) )
83 { 83 {
84 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); 84 Log_err( "Error opening %s for r/w (%s)", name, errMsg() );
85 return FALSE; 85 return FALSE;
86 } 86 }
87 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); 87 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name );
623 623
624 ASSERT( dbNew.dbf == NULL ); 624 ASSERT( dbNew.dbf == NULL );
625 snprintf( name, MAXCHAR, ARTICLE_NEW_FILENAME_FMT, Cfg_spoolDir() ); 625 snprintf( name, MAXCHAR, ARTICLE_NEW_FILENAME_FMT, Cfg_spoolDir() );
626 flags = GDBM_WRCREAT | GDBM_FAST; 626 flags = GDBM_WRCREAT | GDBM_FAST;
627 627
628 if ( ! ( dbNew.dbf = gdbm_open( name, 512, flags, 0644, NULL ) ) ) 628 if ( ! ( dbNew.dbf = gdbm_open( name, 512, flags, 0644, Log_gdbm_fatal ) ) )
629 { 629 {
630 Log_err( "Error opening %s for r/w (%s)", name, errMsg() ); 630 Log_err( "Error opening %s for r/w (%s)", name, errMsg() );
631 return FALSE; 631 return FALSE;
632 } 632 }
633 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name ); 633 Log_dbg( LOG_DBG_NEWSBASE, "%s opened for r/w", name );