shill: cellular: Don't hang on to the Device instance just for termination.
The Cellular device used to register a termination hook using a
reference counted pointer to its instance. This prevented shill from
destructing the Cellular device instance when all other references
were eliminated (e.g., when a Modem RPC instance disappeared) which
caused a shill crash on Modem RPC reappearance.
This patch switches the termination hook to a weak pointer which
allows Cellular device destruction.
BUG=chromium-os:34398
TEST=see bug report
Change-Id: I0bb7622e54e67000d4fa7c98ed11d9657ade2d8d
Reviewed-on: https://gerrit.chromium.org/gerrit/33196
Tested-by: Darin Petkov <petkov@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Reviewed-by: Gary Morain <gmorain@chromium.org>
Commit-Ready: Darin Petkov <petkov@chromium.org>
diff --git a/cellular.cc b/cellular.cc
index dce2442..222ceb3 100644
--- a/cellular.cc
+++ b/cellular.cc
@@ -441,7 +441,8 @@
VLOG(2) << "Already connected";
return;
}
- Closure start_cb = Bind(&Cellular::StartTermination, this);
+ Closure start_cb = Bind(&Cellular::StartTermination,
+ weak_ptr_factory_.GetWeakPtr());
manager()->AddTerminationAction(FriendlyName(), start_cb);
SetState(kStateConnected);
if (!capability_->AllowRoaming() &&