avoid bogus reconnect message
authorChristian Grothoff <christian@grothoff.org>
Tue, 26 Feb 2019 08:39:07 +0000 (09:39 +0100)
committerChristian Grothoff <christian@grothoff.org>
Tue, 26 Feb 2019 08:39:51 +0000 (09:39 +0100)
src/core/core_api_monitor_peers.c

index 8820b44d1e0575fc8ba3eea8942066c7834a1b00..0ebb94d7b26bb28e773bd6746c61912246902339 100644 (file)
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
@@ -135,10 +135,11 @@ reconnect (struct GNUNET_CORE_MonitorHandle *mh)
   if (NULL == mh->mq)
     return;
   /* notify callback about reconnect */
-  mh->peer_cb (mh->peer_cb_cls,
-               NULL,
-               GNUNET_CORE_KX_CORE_DISCONNECT,
-               GNUNET_TIME_UNIT_FOREVER_ABS);
+  if (NULL != mh->peer_cb)
+    mh->peer_cb (mh->peer_cb_cls,
+                 NULL,
+                 GNUNET_CORE_KX_CORE_DISCONNECT,
+                 GNUNET_TIME_UNIT_FOREVER_ABS);
   env = GNUNET_MQ_msg (msg,
                        GNUNET_MESSAGE_TYPE_CORE_MONITOR_PEERS);
   GNUNET_MQ_send (mh->mq,
@@ -172,9 +173,9 @@ GNUNET_CORE_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   GNUNET_assert (NULL != peer_cb);
   mh = GNUNET_new (struct GNUNET_CORE_MonitorHandle);
   mh->cfg = cfg;
+  reconnect (mh);
   mh->peer_cb = peer_cb;
   mh->peer_cb_cls = peer_cb_cls;
-  reconnect (mh);
   if (NULL == mh->mq)
   {
     GNUNET_free (mh);