monclient: add an initialized bool to guard shutdown.

The addition of a Finisher in 9c56070bc2
broke shutdown in the case where MonClient::init() was never called, so
add a guard variable to keep track.

I'm not sure this is actually the best solution (Timer guard itself,
for instance; maybe Finisher should too?), but I don't want to change
the Finisher interface without looking at it more carefully than I'm
going to right now.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
This commit is contained in:
Greg Farnum 2011-10-05 09:50:51 -07:00
parent 3bb6ad9d20
commit b5c27aec40
2 changed files with 7 additions and 1 deletions

View File

@ -51,6 +51,7 @@ MonClient::MonClient(CephContext *cct_) :
cur_con(NULL),
monc_lock("MonClient::monc_lock"),
timer(cct_, monc_lock), finisher(cct_),
initialized(false),
log_client(NULL),
hunting(true),
want_monmap(true),
@ -376,12 +377,16 @@ int MonClient::init()
ldout(cct, 0) << "WARNING: unknown auth protocol defined: " << *iter << dendl;
}
}
initialized = true;
return 0;
}
void MonClient::shutdown()
{
finisher.stop();
if (initialized) {
finisher.stop();
}
monc_lock.Lock();
timer.shutdown();
if (cur_con) {

View File

@ -64,6 +64,7 @@ private:
Mutex monc_lock;
SafeTimer timer;
Finisher finisher;
bool initialized;
LogClient *log_client;