]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/MgrClient: store registered event returned by add_event_after()
authorKefu Chai <kchai@redhat.com>
Mon, 23 Oct 2017 03:50:24 +0000 (11:50 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 24 Oct 2017 08:06:26 +0000 (16:06 +0800)
to be consistent with other caller sites of add_event_after(). the
original intention of doing so, is to avoid double free of the callback
to be added if we are stopping and the timer refuses to add this
callback.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/MgrClient.cc

index 25f365da361ef7022e188f6582c0a4760e5f95f4..26b27df76913a49860feb1b0a9a79a9a83c1dfe7 100644 (file)
@@ -221,8 +221,11 @@ void MgrClient::send_stats()
   send_report();
   send_pgstats();
   if (stats_period != 0) {
-    report_callback = new FunctionContext([this](int){send_stats();});
-    timer.add_event_after(stats_period, report_callback);
+    report_callback = timer.add_event_after(
+      stats_period,
+      new FunctionContext([this](int) {
+         send_stats();
+       }));
   }
 }