Check if the object is still valid in the timeout callback function

When the SOL module in netipmid is busy, there is a chance that the
timeout callback function is executed after the context object is
destructed.  This will cause the process to crash with this error:

terminate called after throwing an instance of
'boost::wrapexcept<boost::asio::bad_executor>'
  what():  bad executor

The root cause is that the cancel() cannot cancel the expired callback
handlers. When the callback handler is executed, the object is deleted
already.

This uses proper reference counting on the objects captured in the
lambda so that they are not referencing memory that has already gone out
of scope.

Tested:
Decrease the accumulateInterval to 50ms for easy reproducing.
Run "ipmitool sel list", "ipmitool sensor list"
and "ipmitool sol looptest 200 500" at the same time,
no "sol looptest fail" error

Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Change-Id: I4b9e4ebce14ff5fca8e991aed96643186c9ea5d9
4 files changed