Fix heisenbug in journaling.
This commit is contained in:
parent
4a7533b6d6
commit
dbc73860ca
|
@ -89,7 +89,7 @@ Loggable::open ( const char *filename )
|
||||||
|
|
||||||
if ( newer( "snapshot", filename ) )
|
if ( newer( "snapshot", filename ) )
|
||||||
{
|
{
|
||||||
DMESSAGE( "Loading snapshot" );
|
MESSAGE( "Loading snapshot" );
|
||||||
|
|
||||||
FILE *fp = fopen( "snapshot", "r" );
|
FILE *fp = fopen( "snapshot", "r" );
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ Loggable::open ( const char *filename )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DMESSAGE( "Replaying journal" );
|
MESSAGE( "Replaying journal" );
|
||||||
|
|
||||||
replay( fp );
|
replay( fp );
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,8 @@ Loggable::close ( void )
|
||||||
|
|
||||||
_fp = NULL;
|
_fp = NULL;
|
||||||
|
|
||||||
snapshot( "snapshot" );
|
if ( ! snapshot( "snapshot" ) )
|
||||||
|
WARNING( "Failed to create snapshot" );
|
||||||
|
|
||||||
for ( int i = 0; i < _log_id - 1; ++i )
|
for ( int i = 0; i < _log_id - 1; ++i )
|
||||||
{
|
{
|
||||||
|
@ -204,7 +205,8 @@ Loggable::update_id ( int id )
|
||||||
/* make sure it'll fit */
|
/* make sure it'll fit */
|
||||||
ensure_size( _id );
|
ensure_size( _id );
|
||||||
|
|
||||||
ASSERT( ! _loggables[ _id - 1 ], "Attempt to create object with an ID (0x%X) that already exists. The existing object is of type \"%s\", the new one is \"%s\". Corrupt journal?", _id, _loggables[ _id - 1 ]->class_name(), class_name() );
|
if ( _loggables[ _id - 1 ] )
|
||||||
|
FATAL( "Attempt to create object with an ID (0x%X) that already exists. The existing object is of type \"%s\", the new one is \"%s\". Corrupt journal?", _id, _loggables[ _id - 1 ]->class_name(), class_name() );
|
||||||
|
|
||||||
_loggables[ _id - 1 ] = this;
|
_loggables[ _id - 1 ] = this;
|
||||||
}
|
}
|
||||||
|
@ -418,11 +420,11 @@ Loggable::snapshot ( const char *name )
|
||||||
if ( ! ( fp = fopen( name, "w" ) ))
|
if ( ! ( fp = fopen( name, "w" ) ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
snapshot( fp );
|
bool r = snapshot( fp );
|
||||||
|
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
|
|
||||||
return true;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Replace the journal with a snapshot of the current state */
|
/** Replace the journal with a snapshot of the current state */
|
||||||
|
|
|
@ -148,7 +148,9 @@ public:
|
||||||
void
|
void
|
||||||
block_end ( void )
|
block_end ( void )
|
||||||
{
|
{
|
||||||
assert( --Loggable::_level >= 0 );
|
--Loggable::_level;
|
||||||
|
|
||||||
|
ASSERT( Loggable::_level >= 0, "Programming error" );
|
||||||
|
|
||||||
if ( Loggable::_level == 0 )
|
if ( Loggable::_level == 0 )
|
||||||
flush();
|
flush();
|
||||||
|
|
Loading…
Reference in New Issue