Add some error checking to unjournaled state save/load.
This commit is contained in:
parent
0032dce478
commit
f365b9d8f7
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue