+struct DuplicateStats
+{
+ /**
+ * Next item in the list
+ */
+ struct DuplicateStats *next;
+
+ /**
+ * Nasty string, concatenation of relevant information.
+ */
+ char *unique_string;
+};
+
+/**
+ * Check whether the combination of port/host/unix domain socket
+ * already exists in the list of peers being checked for statistics.
+ *
+ * @param pg the peergroup in question
+ * @param specific_peer the peer we're concerned with
+ * @param stats_list the list to return to the caller
+ *
+ * @return GNUNET_YES if the statistics instance has been seen already,
+ * GNUNET_NO if not (and we may have added it to the list)
+ */
+static int
+stats_check_existing (struct GNUNET_TESTING_PeerGroup *pg,
+ struct PeerData *specific_peer,
+ struct DuplicateStats **stats_list)
+{
+ struct DuplicateStats *pos;
+ char *unix_domain_socket;
+ unsigned long long port;
+ char *to_match;
+ if (GNUNET_YES !=
+ GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing",
+ "single_statistics_per_host"))
+ return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */
+
+ pos = *stats_list;
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, "statistics",
+ "unixpath", &unix_domain_socket))
+ return GNUNET_NO;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, "statistics",
+ "port", &port))
+ {
+ GNUNET_free(unix_domain_socket);
+ return GNUNET_NO;
+ }
+
+ if (specific_peer->daemon->hostname != NULL)
+ GNUNET_asprintf (&to_match, "%s%s%llu", specific_peer->daemon->hostname,
+ unix_domain_socket, port);
+ else
+ GNUNET_asprintf (&to_match, "%s%llu", unix_domain_socket, port);
+
+ while (pos != NULL)
+ {
+ if (0 == strcmp (to_match, pos->unique_string))
+ {
+ GNUNET_free (unix_domain_socket);
+ GNUNET_free (to_match);
+ return GNUNET_YES;
+ }
+ pos = pos->next;
+ }
+ pos = GNUNET_malloc (sizeof (struct DuplicateStats));
+ pos->unique_string = to_match;
+ pos->next = *stats_list;
+ *stats_list = pos;
+ GNUNET_free (unix_domain_socket);
+ return GNUNET_NO;
+}