nonlib: Always get the latest unjournaled state when saving.
This commit is contained in:
parent
13b6537ee4
commit
6f993eeb10
|
@ -244,17 +244,17 @@ Loggable::close ( void )
|
||||||
if ( ! snapshot( "snapshot" ) )
|
if ( ! snapshot( "snapshot" ) )
|
||||||
WARNING( "Failed to create snapshot" );
|
WARNING( "Failed to create snapshot" );
|
||||||
|
|
||||||
|
if ( ! save_unjournaled_state() )
|
||||||
|
WARNING( "Failed to save unjournaled state" );
|
||||||
|
|
||||||
for ( std::map <unsigned int, Loggable::log_pair >::iterator i = _loggables.begin();
|
for ( std::map <unsigned int, Loggable::log_pair >::iterator i = _loggables.begin();
|
||||||
i != _loggables.end(); ++i )
|
i != _loggables.end(); ++i )
|
||||||
|
{
|
||||||
if ( i->second.loggable )
|
if ( i->second.loggable )
|
||||||
delete i->second.loggable;
|
delete i->second.loggable;
|
||||||
|
|
||||||
save_unjournaled_state();
|
|
||||||
|
|
||||||
for ( std::map <unsigned int, Loggable::log_pair >::iterator i = _loggables.begin();
|
|
||||||
i != _loggables.end(); ++i )
|
|
||||||
if ( i->second.unjournaled_state )
|
if ( i->second.unjournaled_state )
|
||||||
delete i->second.unjournaled_state;
|
delete i->second.unjournaled_state;
|
||||||
|
}
|
||||||
|
|
||||||
_loggables.clear();
|
_loggables.clear();
|
||||||
|
|
||||||
|
@ -279,6 +279,10 @@ Loggable::save_unjournaled_state ( void )
|
||||||
for ( std::map <unsigned int, Loggable::log_pair >::iterator i = _loggables.begin();
|
for ( std::map <unsigned int, Loggable::log_pair >::iterator i = _loggables.begin();
|
||||||
i != _loggables.end(); ++i )
|
i != _loggables.end(); ++i )
|
||||||
{
|
{
|
||||||
|
/* get the latest state */
|
||||||
|
if ( i->second.loggable )
|
||||||
|
i->second.loggable->record_unjournaled();
|
||||||
|
|
||||||
if ( i->second.unjournaled_state )
|
if ( i->second.unjournaled_state )
|
||||||
{
|
{
|
||||||
char *s = i->second.unjournaled_state->print();
|
char *s = i->second.unjournaled_state->print();
|
||||||
|
@ -782,20 +786,19 @@ Loggable::record_unjournaled ( void ) const
|
||||||
|
|
||||||
get_unjournaled( *e );
|
get_unjournaled( *e );
|
||||||
|
|
||||||
Log_Entry *le = _loggables[ _id ].unjournaled_state;
|
Log_Entry **le = &_loggables[ _id ].unjournaled_state;
|
||||||
|
|
||||||
if ( le )
|
if ( *le )
|
||||||
delete le;
|
{
|
||||||
|
delete *le;
|
||||||
|
*le = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ( e->size() )
|
if ( e->size() )
|
||||||
_loggables[ _id ].unjournaled_state = e;
|
*le = e;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
/* don't waste space on loggables with no unjournaled properties */
|
|
||||||
_loggables[ _id ].unjournaled_state = NULL;
|
|
||||||
delete e;
|
delete e;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Log object destruction. *Must* be called at the beginning of the
|
/** Log object destruction. *Must* be called at the beginning of the
|
||||||
* destructors of leaf classes */
|
* destructors of leaf classes */
|
||||||
|
@ -804,15 +807,15 @@ Loggable::log_destroy ( void ) const
|
||||||
{
|
{
|
||||||
Locker lock( _lock );;
|
Locker lock( _lock );;
|
||||||
|
|
||||||
/* the unjournaled state may have changed: make a note of it. */
|
|
||||||
record_unjournaled();
|
|
||||||
|
|
||||||
set_dirty();
|
set_dirty();
|
||||||
|
|
||||||
if ( ! _fp )
|
if ( ! _fp )
|
||||||
/* tearing down... don't bother */
|
/* tearing down... don't bother */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* the unjournaled state may have changed: make a note of it. */
|
||||||
|
record_unjournaled();
|
||||||
|
|
||||||
log( "%s 0x%X destroy << ", class_name(), _id );
|
log( "%s 0x%X destroy << ", class_name(), _id );
|
||||||
|
|
||||||
Log_Entry e;
|
Log_Entry e;
|
||||||
|
|
Loading…
Reference in New Issue