+static void
+notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+{
+ struct PeerContext *p = cls;
+ char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, ps,
+ GNUNET_i2s (peer));
+
+ if (th != NULL)
+ GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
+ th = NULL;
+
+ if (shutdown_ == GNUNET_YES)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Complete, shutting down...\n");
+ GNUNET_SCHEDULER_add_now (&end, NULL);
+ }
+}
+
+
+static void
+stop_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
+ return;
+
+ struct PeerContext *p = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down peer %u (`%s')\n", p->no,
+ GNUNET_i2s (&p->id));
+ shutdown_ = GNUNET_YES;
+ GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
+ p2 = NULL;
+ GNUNET_assert (p2 == NULL);
+}