Skip to content

Commit 88167ad

Browse files
authored
Merge pull request #1364 from cogutvalera/issue_1314
Terminate block production loop when shutting down witness plugin #1314
2 parents 3621477 + 035eee2 commit 88167ad

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

libraries/plugins/witness/witness.cpp

+24-12
Original file line numberDiff line numberDiff line change
@@ -192,23 +192,29 @@ void witness_plugin::schedule_production_loop()
192192

193193
block_production_condition::block_production_condition_enum witness_plugin::block_production_loop()
194194
{
195-
if (_shutting_down) return block_production_condition::block_production_condition_enum::shutdown;
196-
197195
block_production_condition::block_production_condition_enum result;
198196
fc::limited_mutable_variant_object capture( GRAPHENE_MAX_NESTED_OBJECTS );
199-
try
200-
{
201-
result = maybe_produce_block(capture);
202-
}
203-
catch( const fc::canceled_exception& )
197+
198+
if (_shutting_down)
204199
{
205-
//We're trying to exit. Go ahead and let this one out.
206-
throw;
200+
result = block_production_condition::shutdown;
207201
}
208-
catch( const fc::exception& e )
202+
else
209203
{
210-
elog("Got exception while generating block:\n${e}", ("e", e.to_detail_string()));
211-
result = block_production_condition::exception_producing_block;
204+
try
205+
{
206+
result = maybe_produce_block(capture);
207+
}
208+
catch( const fc::canceled_exception& )
209+
{
210+
//We're trying to exit. Go ahead and let this one out.
211+
throw;
212+
}
213+
catch( const fc::exception& e )
214+
{
215+
elog("Got exception while generating block:\n${e}", ("e", e.to_detail_string()));
216+
result = block_production_condition::exception_producing_block;
217+
}
212218
}
213219

214220
switch( result )
@@ -235,6 +241,12 @@ block_production_condition::block_production_condition_enum witness_plugin::bloc
235241
case block_production_condition::exception_producing_block:
236242
elog( "exception producing block" );
237243
break;
244+
case block_production_condition::shutdown:
245+
ilog( "shutdown producing block" );
246+
return result;
247+
default:
248+
elog( "unknown condition ${result} while producing block", ("result", (unsigned char)result) );
249+
break;
238250
}
239251

240252
schedule_production_loop();

0 commit comments

Comments
 (0)