Add some error checking to unjournaled state save/load.

pull/3/head
Jonathan Moore Liles 2009-01-11 17:57:36 -06:00
parent 0032dce478
commit f365b9d8f7
1 changed files with 11 additions and 6 deletions

View File

@ -143,7 +143,10 @@ Loggable::load_unjournaled_state ( void )
fp = fopen( "unjournaled", "r" );
if ( ! fp )
{
DWARNING( "Could not open unjournaled state file for reading" );
return false;
}
unsigned int id;
char buf[BUFSIZ];
@ -239,12 +242,16 @@ Loggable::close ( void )
bool
Loggable::save_unjournaled_state ( void )
{
FILE *fp;
/* FIXME: check for errors */
FILE *fp = fopen( "unjournaled", "w" );
fp = fopen( "unjournaled", "w" );
if ( ! fp )
{
DWARNING( "Could not open unjournaled state file for writing!" );
return false;
}
/* write out the unjournaled state of all currently active
* loggables */
for ( std::map <unsigned int, Log_Entry *>::iterator i = _loggables_unjournaled.begin();
i != _loggables_unjournaled.end(); ++i )
{
@ -258,8 +265,6 @@ Loggable::save_unjournaled_state ( void )
}
}
/* write out the remembered state of inactive loggables. */
fclose( fp );
return true;