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