aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c973
1 files changed, 478 insertions, 495 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 723afd456..d03cb307b 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -87,12 +87,13 @@ enum PeerLists
87 * Prototype of a function called whenever two peers would be connected 87 * Prototype of a function called whenever two peers would be connected
88 * in a certain topology. 88 * in a certain topology.
89 */ 89 */
90typedef unsigned int 90typedef unsigned int (*GNUNET_TESTING_ConnectionProcessor) (struct
91 (*GNUNET_TESTING_ConnectionProcessor) (struct GNUNET_TESTING_PeerGroup * pg, 91 GNUNET_TESTING_PeerGroup
92 unsigned int first, 92 * pg,
93 unsigned int second, 93 unsigned int first,
94 enum PeerLists list, 94 unsigned int second,
95 unsigned int check); 95 enum PeerLists list,
96 unsigned int check);
96 97
97/** 98/**
98 * Context for handling churning a peer group 99 * Context for handling churning a peer group
@@ -1091,8 +1092,8 @@ update_meter (struct ProgressMeter *meter)
1091 fprintf (stdout, "%sProgress: [0%%", meter->startup_string); 1092 fprintf (stdout, "%sProgress: [0%%", meter->startup_string);
1092 } 1093 }
1093 else 1094 else
1094 fprintf (stdout, "%d%%", (int) (((float) meter->completed 1095 fprintf (stdout, "%d%%",
1095 / meter->total) * 100)); 1096 (int) (((float) meter->completed / meter->total) * 100));
1096 } 1097 }
1097 else if (meter->completed % meter->dotnum == 0) 1098 else if (meter->completed % meter->dotnum == 0)
1098 fprintf (stdout, "."); 1099 fprintf (stdout, ".");
@@ -1332,24 +1333,24 @@ update_config (void *cls, const char *section, const char *option,
1332 1333
1333 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival))) 1334 if ((0 == strcmp (option, "PORT")) && (1 == sscanf (value, "%u", &ival)))
1334 { 1335 {
1335 if ((ival != 0) && (GNUNET_YES 1336 if ((ival != 0) &&
1336 != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1337 (GNUNET_YES !=
1337 "testing", 1338 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1338 single_variable))) 1339 single_variable)))
1339 { 1340 {
1340 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++); 1341 GNUNET_snprintf (cval, sizeof (cval), "%u", ctx->nport++);
1341 value = cval; 1342 value = cval;
1342 } 1343 }
1343 else if ((ival != 0) && (GNUNET_YES 1344 else if ((ival != 0) &&
1344 == GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1345 (GNUNET_YES ==
1345 "testing", 1346 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1346 single_variable)) 1347 single_variable)) &&
1347 && GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", 1348 GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
1348 per_host_variable, 1349 per_host_variable,
1349 &num_per_host)) 1350 &num_per_host))
1350 { 1351 {
1351 GNUNET_snprintf (cval, sizeof (cval), "%u", ival + ctx->fdnum 1352 GNUNET_snprintf (cval, sizeof (cval), "%u",
1352 % num_per_host); 1353 ival + ctx->fdnum % num_per_host);
1353 value = cval; 1354 value = cval;
1354 } 1355 }
1355 1356
@@ -1361,23 +1362,23 @@ update_config (void *cls, const char *section, const char *option,
1361 1362
1362 if (0 == strcmp (option, "UNIXPATH")) 1363 if (0 == strcmp (option, "UNIXPATH"))
1363 { 1364 {
1364 if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, 1365 if (GNUNET_YES !=
1365 "testing", 1366 GNUNET_CONFIGURATION_get_value_yesno (ctx->orig, "testing",
1366 single_variable)) 1367 single_variable))
1367 { 1368 {
1368 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", 1369 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
1369 section, ctx->upnum++); 1370 ctx->upnum++);
1370 value = uval; 1371 value = uval;
1371 } 1372 }
1372 else if ((GNUNET_YES 1373 else if ((GNUNET_YES ==
1373 == GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing", 1374 GNUNET_CONFIGURATION_get_value_number (ctx->orig, "testing",
1374 per_host_variable, 1375 per_host_variable,
1375 &num_per_host)) 1376 &num_per_host)) &&
1376 && (num_per_host > 0)) 1377 (num_per_host > 0))
1377 1378
1378 { 1379 {
1379 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", 1380 GNUNET_snprintf (uval, sizeof (uval), "/tmp/test-service-%s-%u", section,
1380 section, ctx->fdnum % num_per_host); 1381 ctx->fdnum % num_per_host);
1381 value = uval; 1382 value = uval;
1382 } 1383 }
1383 } 1384 }
@@ -1437,10 +1438,10 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1437 return NULL; 1438 return NULL;
1438 } 1439 }
1439 1440
1440 if ((GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", 1441 if ((GNUNET_OK ==
1441 "skew_variance", 1442 GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "skew_variance",
1442 &skew_variance)) 1443 &skew_variance)) &&
1443 && (skew_variance > 0)) 1444 (skew_variance > 0))
1444 { 1445 {
1445 skew_offset = 1446 skew_offset =
1446 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1447 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
@@ -1454,8 +1455,8 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1454 skew_offset); 1455 skew_offset);
1455 } 1456 }
1456 1457
1457 if (GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "control_host", 1458 if (GNUNET_CONFIGURATION_get_value_string
1458 &control_host) == GNUNET_OK) 1459 (cfg, "testing", "control_host", &control_host) == GNUNET_OK)
1459 { 1460 {
1460 if (hostname != NULL) 1461 if (hostname != NULL)
1461 GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host, 1462 GNUNET_asprintf (&allowed_hosts, "%s; 127.0.0.1; %s;", control_host,
@@ -1469,12 +1470,12 @@ make_config (const struct GNUNET_CONFIGURATION_Handle *cfg, uint32_t off,
1469 GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM", 1470 GNUNET_CONFIGURATION_set_value_string (uc.ret, "nse", "ACCEPT_FROM",
1470 allowed_hosts); 1471 allowed_hosts);
1471 1472
1472 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", 1473 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "ACCEPT_FROM",
1473 "ACCEPT_FROM", allowed_hosts); 1474 allowed_hosts);
1474 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM", 1475 GNUNET_CONFIGURATION_set_value_string (uc.ret, "dht", "ACCEPT_FROM",
1475 allowed_hosts); 1476 allowed_hosts);
1476 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", 1477 GNUNET_CONFIGURATION_set_value_string (uc.ret, "statistics", "ACCEPT_FROM",
1477 "ACCEPT_FROM", allowed_hosts); 1478 allowed_hosts);
1478 1479
1479 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", ""); 1480 GNUNET_CONFIGURATION_set_value_string (uc.ret, "core", "UNIXPATH", "");
1480 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", ""); 1481 GNUNET_CONFIGURATION_set_value_string (uc.ret, "transport", "UNIXPATH", "");
@@ -1629,23 +1630,19 @@ remove_connections (struct GNUNET_TESTING_PeerGroup *pg, unsigned int first,
1629 } 1630 }
1630#else 1631#else
1631 if (GNUNET_YES == 1632 if (GNUNET_YES ==
1632 GNUNET_CONTAINER_multihashmap_contains (pg-> 1633 GNUNET_CONTAINER_multihashmap_contains (pg->peers[first].
1633 peers[first].blacklisted_peers, 1634 blacklisted_peers, &hash_second))
1634 &hash_second))
1635 { 1635 {
1636 GNUNET_CONTAINER_multihashmap_remove_all (pg-> 1636 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[first].
1637 peers[first].blacklisted_peers, 1637 blacklisted_peers, &hash_second);
1638 &hash_second);
1639 } 1638 }
1640 1639
1641 if (GNUNET_YES == 1640 if (GNUNET_YES ==
1642 GNUNET_CONTAINER_multihashmap_contains (pg-> 1641 GNUNET_CONTAINER_multihashmap_contains (pg->peers[second].
1643 peers[second].blacklisted_peers, 1642 blacklisted_peers, &hash_first))
1644 &hash_first))
1645 { 1643 {
1646 GNUNET_CONTAINER_multihashmap_remove_all (pg-> 1644 GNUNET_CONTAINER_multihashmap_remove_all (pg->peers[second].
1647 peers[second].blacklisted_peers, 1645 blacklisted_peers, &hash_first);
1648 &hash_first);
1649 } 1646 }
1650#endif 1647#endif
1651 1648
@@ -1801,22 +1798,22 @@ create_scale_free (struct GNUNET_TESTING_PeerGroup *pg,
1801 previous_total_connections = total_connections; 1798 previous_total_connections = total_connections;
1802 for (i = 0; i < outer_count; i++) 1799 for (i = 0; i < outer_count; i++)
1803 { 1800 {
1804 probability = pg->peers[i].num_connections 1801 probability =
1805 / (double) previous_total_connections; 1802 pg->peers[i].num_connections / (double) previous_total_connections;
1806 random 1803 random =
1807 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1804 ((double)
1808 UINT64_MAX)) 1805 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
1809 / ((double) UINT64_MAX); 1806 UINT64_MAX)) / ((double) UINT64_MAX);
1810#if VERBOSE_TESTING 1807#if VERBOSE_TESTING
1811 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1808 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1812 "Considering connecting peer %d to peer %d\n", 1809 "Considering connecting peer %d to peer %d\n", outer_count,
1813 outer_count, i); 1810 i);
1814#endif 1811#endif
1815 if (random < probability) 1812 if (random < probability)
1816 { 1813 {
1817#if VERBOSE_TESTING 1814#if VERBOSE_TESTING
1818 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1815 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
1819 "Connecting peer %d to peer %d\n", outer_count, i); 1816 outer_count, i);
1820#endif 1817#endif
1821 total_connections += proc (pg, outer_count, i, list, GNUNET_YES); 1818 total_connections += proc (pg, outer_count, i, list, GNUNET_YES);
1822 } 1819 }
@@ -1872,9 +1869,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1872 int connect_attempts; 1869 int connect_attempts;
1873 1870
1874 logNModifier = 0.5; /* FIXME: default value? */ 1871 logNModifier = 0.5; /* FIXME: default value? */
1875 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1872 if (GNUNET_OK ==
1876 "PERCENTAGE", 1873 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
1877 &p_string)) 1874 &p_string))
1878 { 1875 {
1879 if (sscanf (p_string, "%lf", &logNModifier) != 1) 1876 if (sscanf (p_string, "%lf", &logNModifier) != 1)
1880 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1877 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1884,9 +1881,9 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1884 GNUNET_free (p_string); 1881 GNUNET_free (p_string);
1885 } 1882 }
1886 probability = 0.5; /* FIXME: default percentage? */ 1883 probability = 0.5; /* FIXME: default percentage? */
1887 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1884 if (GNUNET_OK ==
1888 "PROBABILITY", 1885 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
1889 &p_string)) 1886 &p_string))
1890 { 1887 {
1891 if (sscanf (p_string, "%lf", &probability) != 1) 1888 if (sscanf (p_string, "%lf", &probability) != 1)
1892 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1889 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1926,22 +1923,20 @@ create_small_world_ring (struct GNUNET_TESTING_PeerGroup *pg,
1926 1923
1927 for (j = 0; j < connsPerPeer / 2; j++) 1924 for (j = 0; j < connsPerPeer / 2; j++)
1928 { 1925 {
1929 random 1926 random =
1930 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 1927 ((double)
1931 UINT64_MAX) 1928 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
1932 / ((double) UINT64_MAX)); 1929 UINT64_MAX) / ((double) UINT64_MAX));
1933 if (random < probability) 1930 if (random < probability)
1934 { 1931 {
1935 /* Connect to uniformly selected random peer */ 1932 /* Connect to uniformly selected random peer */
1936 randomPeer 1933 randomPeer =
1937 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 1934 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
1938 while ((((randomPeer < max) && (randomPeer > min)) && (useAnd 1935 while ((((randomPeer < max) && (randomPeer > min)) && (useAnd == 0)) ||
1939 == 0)) ||
1940 (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1))) 1936 (((randomPeer > min) || (randomPeer < max)) && (useAnd == 1)))
1941 { 1937 {
1942 randomPeer 1938 randomPeer =
1943 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 1939 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
1944 pg->total);
1945 } 1940 }
1946 smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES); 1941 smallWorldConnections += proc (pg, i, randomPeer, list, GNUNET_YES);
1947 } 1942 }
@@ -1987,9 +1982,9 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg,
1987 char *p_string; 1982 char *p_string;
1988 1983
1989 nat_percentage = 0.6; /* FIXME: default percentage? */ 1984 nat_percentage = 0.6; /* FIXME: default percentage? */
1990 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 1985 if (GNUNET_OK ==
1991 "PERCENTAGE", 1986 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
1992 &p_string)) 1987 &p_string))
1993 { 1988 {
1994 if (sscanf (p_string, "%lf", &nat_percentage) != 1) 1989 if (sscanf (p_string, "%lf", &nat_percentage) != 1)
1995 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1990 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2008,12 +2003,11 @@ create_nated_internet (struct GNUNET_TESTING_PeerGroup *pg,
2008 if ((outer_count > cutoff) || (inner_count > cutoff)) 2003 if ((outer_count > cutoff) || (inner_count > cutoff))
2009 { 2004 {
2010#if VERBOSE_TESTING 2005#if VERBOSE_TESTING
2011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2012 "Connecting peer %d to peer %d\n",
2013 outer_count, inner_count); 2007 outer_count, inner_count);
2014#endif 2008#endif
2015 connect_attempts += proc (pg, outer_count, inner_count, list, 2009 connect_attempts +=
2016 GNUNET_YES); 2010 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2017 } 2011 }
2018 } 2012 }
2019 } 2013 }
@@ -2047,9 +2041,9 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg,
2047 struct ProgressMeter *conn_meter; 2041 struct ProgressMeter *conn_meter;
2048 2042
2049 nat_percentage = 0.6; /* FIXME: default percentage? */ 2043 nat_percentage = 0.6; /* FIXME: default percentage? */
2050 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2044 if (GNUNET_OK ==
2051 "PERCENTAGE", 2045 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
2052 &p_string)) 2046 &p_string))
2053 { 2047 {
2054 if (sscanf (p_string, "%lf", &nat_percentage) != 1) 2048 if (sscanf (p_string, "%lf", &nat_percentage) != 1)
2055 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2049 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2080,12 +2074,11 @@ create_nated_internet_copy (struct GNUNET_TESTING_PeerGroup *pg,
2080 if ((outer_count > cutoff) || (inner_count > cutoff)) 2074 if ((outer_count > cutoff) || (inner_count > cutoff))
2081 { 2075 {
2082#if VERBOSE_TESTING 2076#if VERBOSE_TESTING
2083 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2077 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2084 "Connecting peer %d to peer %d\n",
2085 outer_count, inner_count); 2078 outer_count, inner_count);
2086#endif 2079#endif
2087 connect_attempts += proc (pg, outer_count, inner_count, list, 2080 connect_attempts +=
2088 GNUNET_YES); 2081 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2089 add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO); 2082 add_connections (pg, outer_count, inner_count, ALLOWED, GNUNET_NO);
2090 update_meter (conn_meter); 2083 update_meter (conn_meter);
2091 } 2084 }
@@ -2137,9 +2130,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2137 cols = square; 2130 cols = square;
2138 2131
2139 percentage = 0.5; /* FIXME: default percentage? */ 2132 percentage = 0.5; /* FIXME: default percentage? */
2140 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2133 if (GNUNET_OK ==
2141 "PERCENTAGE", 2134 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PERCENTAGE",
2142 &p_string)) 2135 &p_string))
2143 { 2136 {
2144 if (sscanf (p_string, "%lf", &percentage) != 1) 2137 if (sscanf (p_string, "%lf", &percentage) != 1)
2145 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2138 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2157,9 +2150,9 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2157 percentage = 0.5; 2150 percentage = 0.5;
2158 } 2151 }
2159 probability = 0.5; /* FIXME: default percentage? */ 2152 probability = 0.5; /* FIXME: default percentage? */
2160 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2153 if (GNUNET_OK ==
2161 "PROBABILITY", 2154 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
2162 &p_string)) 2155 &p_string))
2163 { 2156 {
2164 if (sscanf (p_string, "%lf", &probability) != 1) 2157 if (sscanf (p_string, "%lf", &probability) != 1)
2165 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2158 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2182,8 +2175,7 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2182 } 2175 }
2183#if VERBOSE_TESTING 2176#if VERBOSE_TESTING
2184 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2177 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2185 _ 2178 _("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2186 ("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2187 rows, cols); 2179 rows, cols);
2188#endif 2180#endif
2189 2181
@@ -2220,8 +2212,8 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2220 natLog = log (pg->total); 2212 natLog = log (pg->total);
2221#if VERBOSE_TESTING > 2 2213#if VERBOSE_TESTING > 2
2222 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2223 _("natural log of %d is %d, will run %d iterations\n"), 2215 _("natural log of %d is %d, will run %d iterations\n"), pg->total,
2224 pg->total, natLog, (int) (natLog * percentage)); 2216 natLog, (int) (natLog * percentage));
2225 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2217 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2226 _("Total connections added thus far: %u!\n"), connect_attempts); 2218 _("Total connections added thus far: %u!\n"), connect_attempts);
2227#endif 2219#endif
@@ -2249,10 +2241,10 @@ create_small_world (struct GNUNET_TESTING_PeerGroup *pg,
2249 /* Calculate probability as 1 over the square of the distance */ 2241 /* Calculate probability as 1 over the square of the distance */
2250 probability = 1.0 / (distance * distance); 2242 probability = 1.0 / (distance * distance);
2251 /* Choose a random value between 0 and 1 */ 2243 /* Choose a random value between 0 and 1 */
2252 random 2244 random =
2253 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 2245 ((double)
2254 UINT64_MAX)) 2246 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
2255 / ((double) UINT64_MAX); 2247 UINT64_MAX)) / ((double) UINT64_MAX);
2256 /* If random < probability, then connect the two nodes */ 2248 /* If random < probability, then connect the two nodes */
2257 if (random < probability) 2249 if (random < probability)
2258 smallWorldConnections += proc (pg, j, k, list, GNUNET_YES); 2250 smallWorldConnections += proc (pg, j, k, list, GNUNET_YES);
@@ -2295,9 +2287,9 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg,
2295 char *p_string; 2287 char *p_string;
2296 2288
2297 probability = 0.5; /* FIXME: default percentage? */ 2289 probability = 0.5; /* FIXME: default percentage? */
2298 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", 2290 if (GNUNET_OK ==
2299 "PROBABILITY", 2291 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "TESTING", "PROBABILITY",
2300 &p_string)) 2292 &p_string))
2301 { 2293 {
2302 if (sscanf (p_string, "%lf", &probability) != 1) 2294 if (sscanf (p_string, "%lf", &probability) != 1)
2303 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2295 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -2311,18 +2303,18 @@ create_erdos_renyi (struct GNUNET_TESTING_PeerGroup *pg,
2311 { 2303 {
2312 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) 2304 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
2313 { 2305 {
2314 temp_rand 2306 temp_rand =
2315 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 2307 ((double)
2316 UINT64_MAX)) 2308 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
2317 / ((double) UINT64_MAX); 2309 UINT64_MAX)) / ((double) UINT64_MAX);
2318#if VERBOSE_TESTING 2310#if VERBOSE_TESTING
2319 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2311 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("rand is %f probability is %f\n"),
2320 _("rand is %f probability is %f\n"), temp_rand, probability); 2312 temp_rand, probability);
2321#endif 2313#endif
2322 if (temp_rand < probability) 2314 if (temp_rand < probability)
2323 { 2315 {
2324 connect_attempts += proc (pg, outer_count, inner_count, list, 2316 connect_attempts +=
2325 GNUNET_YES); 2317 proc (pg, outer_count, inner_count, list, GNUNET_YES);
2326 } 2318 }
2327 } 2319 }
2328 } 2320 }
@@ -2376,8 +2368,7 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2376 } 2368 }
2377#if VERBOSE_TESTING 2369#if VERBOSE_TESTING
2378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2379 _ 2371 _("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2380 ("Connecting nodes in 2d torus topology: %u rows %u columns\n"),
2381 rows, cols); 2372 rows, cols);
2382#endif 2373#endif
2383 /* Rows and columns are all sorted out, now iterate over all nodes and connect each 2374 /* Rows and columns are all sorted out, now iterate over all nodes and connect each
@@ -2395,8 +2386,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2395 else 2386 else
2396 nodeToConnect = i - cols + 1; 2387 nodeToConnect = i - cols + 1;
2397#if VERBOSE_TESTING 2388#if VERBOSE_TESTING
2398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2389 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
2399 "Connecting peer %d to peer %d\n", i, nodeToConnect); 2390 nodeToConnect);
2400#endif 2391#endif
2401 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); 2392 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
2402 2393
@@ -2413,8 +2404,8 @@ create_2d_torus (struct GNUNET_TESTING_PeerGroup *pg,
2413 if (nodeToConnect < pg->total) 2404 if (nodeToConnect < pg->total)
2414 { 2405 {
2415#if VERBOSE_TESTING 2406#if VERBOSE_TESTING
2416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2407 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n", i,
2417 "Connecting peer %d to peer %d\n", i, nodeToConnect); 2408 nodeToConnect);
2418#endif 2409#endif
2419 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES); 2410 connect_attempts += proc (pg, i, nodeToConnect, list, GNUNET_YES);
2420 } 2411 }
@@ -2450,15 +2441,16 @@ create_clique (struct GNUNET_TESTING_PeerGroup *pg,
2450 2441
2451 connect_attempts = 0; 2442 connect_attempts = 0;
2452 2443
2453 conn_meter = create_meter ((((pg->total * pg->total) + pg->total) / 2) 2444 conn_meter =
2454 - pg->total, "Create Clique ", GNUNET_NO); 2445 create_meter ((((pg->total * pg->total) + pg->total) / 2) - pg->total,
2446 "Create Clique ", GNUNET_NO);
2455 for (outer_count = 0; outer_count < pg->total - 1; outer_count++) 2447 for (outer_count = 0; outer_count < pg->total - 1; outer_count++)
2456 { 2448 {
2457 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++) 2449 for (inner_count = outer_count + 1; inner_count < pg->total; inner_count++)
2458 { 2450 {
2459#if VERBOSE_TESTING 2451#if VERBOSE_TESTING
2460 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2452 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2461 "Connecting peer %d to peer %d\n", outer_count, inner_count); 2453 outer_count, inner_count);
2462#endif 2454#endif
2463 connect_attempts += proc (pg, outer_count, inner_count, list, check); 2455 connect_attempts += proc (pg, outer_count, inner_count, list, check);
2464 update_meter (conn_meter); 2456 update_meter (conn_meter);
@@ -2568,8 +2560,8 @@ create_line (struct GNUNET_TESTING_PeerGroup *pg,
2568 for (count = 0; count < pg->total - 1; count++) 2560 for (count = 0; count < pg->total - 1; count++)
2569 { 2561 {
2570#if VERBOSE_TESTING 2562#if VERBOSE_TESTING
2571 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2563 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2572 "Connecting peer %d to peer %d\n", count, count + 1); 2564 count, count + 1);
2573#endif 2565#endif
2574 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); 2566 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
2575 } 2567 }
@@ -2691,12 +2683,11 @@ create_from_file (struct GNUNET_TESTING_PeerGroup *pg, char *filename,
2691 return connect_attempts; 2683 return connect_attempts;
2692 } 2684 }
2693 /* Assume file is written with first peer 1, but array index is 0 */ 2685 /* Assume file is written with first peer 1, but array index is 0 */
2694 connect_attempts += proc (pg, first_peer_index - 1, second_peer_index 2686 connect_attempts +=
2695 - 1, list, GNUNET_YES); 2687 proc (pg, first_peer_index - 1, second_peer_index - 1, list,
2696 while ((buf[count] != '\n') && (buf[count] != ',') && (count 2688 GNUNET_YES);
2697 < 2689 while ((buf[count] != '\n') && (buf[count] != ',') &&
2698 frstat.st_size - 2690 (count < frstat.st_size - 1))
2699 1))
2700 count++; 2691 count++;
2701 if (buf[count] == '\n') 2692 if (buf[count] == '\n')
2702 { 2693 {
@@ -2746,8 +2737,8 @@ create_ring (struct GNUNET_TESTING_PeerGroup *pg,
2746 for (count = 0; count < pg->total - 1; count++) 2737 for (count = 0; count < pg->total - 1; count++)
2747 { 2738 {
2748#if VERBOSE_TESTING 2739#if VERBOSE_TESTING
2749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2740 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %d to peer %d\n",
2750 "Connecting peer %d to peer %d\n", count, count + 1); 2741 count, count + 1);
2751#endif 2742#endif
2752 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES); 2743 connect_attempts += proc (pg, count, count + 1, list, GNUNET_YES);
2753 } 2744 }
@@ -2873,8 +2864,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2873 conn_iter = pg->peers[pg_iter].allowed_peers_head; 2864 conn_iter = pg->peers[pg_iter].allowed_peers_head;
2874 while (conn_iter != NULL) 2865 while (conn_iter != NULL)
2875 { 2866 {
2876 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> 2867 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id.
2877 id.hashPubKey, &peer_enc); 2868 hashPubKey, &peer_enc);
2878 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc); 2869 fprintf (temp_friend_handle, "%s\n", (char *) &peer_enc);
2879 conn_iter = conn_iter->next; 2870 conn_iter = conn_iter->next;
2880 } 2871 }
@@ -2885,8 +2876,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2885#endif 2876#endif
2886 fclose (temp_friend_handle); 2877 fclose (temp_friend_handle);
2887 2878
2888 if (GNUNET_OK 2879 if (GNUNET_OK !=
2889 !=
2890 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, 2880 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
2891 "PATHS", "SERVICEHOME", 2881 "PATHS", "SERVICEHOME",
2892 &temp_service_path)) 2882 &temp_service_path))
@@ -2904,8 +2894,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2904 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 2894 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
2905 { 2895 {
2906 GNUNET_asprintf (&arg, "%s/friends", temp_service_path); 2896 GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
2907 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", 2897 procarr[pg_iter] =
2908 mytemp, arg, NULL); 2898 GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
2909 GNUNET_assert (procarr[pg_iter] != NULL); 2899 GNUNET_assert (procarr[pg_iter] != NULL);
2910#if VERBOSE_TESTING 2900#if VERBOSE_TESTING
2911 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2926,8 +2916,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2926 GNUNET_asprintf (&arg, "%s:%s/friends", 2916 GNUNET_asprintf (&arg, "%s:%s/friends",
2927 pg->peers[pg_iter].daemon->hostname, 2917 pg->peers[pg_iter].daemon->hostname,
2928 temp_service_path); 2918 temp_service_path);
2929 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", 2919 procarr[pg_iter] =
2930 mytemp, arg, NULL); 2920 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
2931 GNUNET_assert (procarr[pg_iter] != NULL); 2921 GNUNET_assert (procarr[pg_iter] != NULL);
2932 ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */ 2922 ret = GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: schedule this, throttle! */
2933 GNUNET_OS_process_close (procarr[pg_iter]); 2923 GNUNET_OS_process_close (procarr[pg_iter]);
@@ -2960,13 +2950,13 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2960 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 2950 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
2961 { 2951 {
2962#if VERBOSE_TESTING 2952#if VERBOSE_TESTING
2963 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2953 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking copy status of file %d\n",
2964 "Checking copy status of file %d\n", pg_iter); 2954 pg_iter);
2965#endif 2955#endif
2966 if (procarr[pg_iter] != NULL) /* Check for already completed! */ 2956 if (procarr[pg_iter] != NULL) /* Check for already completed! */
2967 { 2957 {
2968 if (GNUNET_OS_process_status 2958 if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
2969 (procarr[pg_iter], &type, &return_code) != GNUNET_OK) 2959 GNUNET_OK)
2970 { 2960 {
2971 ret = GNUNET_SYSERR; 2961 ret = GNUNET_SYSERR;
2972 } 2962 }
@@ -3061,15 +3051,15 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3061 conn_iter = pg->peers[pg_iter].blacklisted_peers_head; 3051 conn_iter = pg->peers[pg_iter].blacklisted_peers_head;
3062 while (conn_iter != NULL) 3052 while (conn_iter != NULL)
3063 { 3053 {
3064 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon-> 3054 GNUNET_CRYPTO_hash_to_enc (&pg->peers[conn_iter->index].daemon->id.
3065 id.hashPubKey, &peer_enc); 3055 hashPubKey, &peer_enc);
3066 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc); 3056 fprintf (temp_file_handle, "%s:%s\n", pos, (char *) &peer_enc);
3067 conn_iter = conn_iter->next; 3057 conn_iter = conn_iter->next;
3068 } 3058 }
3069#else 3059#else
3070 blacklist_ctx.transport = pos; 3060 blacklist_ctx.transport = pos;
3071 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers 3061 (void) GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].
3072 [pg_iter].blacklisted_peers, 3062 blacklisted_peers,
3073 &blacklist_file_iterator, 3063 &blacklist_file_iterator,
3074 &blacklist_ctx); 3064 &blacklist_ctx);
3075#endif 3065#endif
@@ -3084,8 +3074,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3084 GNUNET_free (temp_transports); 3074 GNUNET_free (temp_transports);
3085 fclose (temp_file_handle); 3075 fclose (temp_file_handle);
3086 3076
3087 if (GNUNET_OK 3077 if (GNUNET_OK !=
3088 !=
3089 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg, 3078 GNUNET_CONFIGURATION_get_value_string (pg->peers[pg_iter].daemon->cfg,
3090 "PATHS", "SERVICEHOME", 3079 "PATHS", "SERVICEHOME",
3091 &temp_service_path)) 3080 &temp_service_path))
@@ -3103,8 +3092,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3103 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 3092 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
3104 { 3093 {
3105 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); 3094 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
3106 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", "mv", 3095 procarr[pg_iter] =
3107 mytemp, arg, NULL); 3096 GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
3108#if VERBOSE_TESTING 3097#if VERBOSE_TESTING
3109 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3098 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3110 _("Copying file with command cp %s %s\n"), mytemp, arg); 3099 _("Copying file with command cp %s %s\n"), mytemp, arg);
@@ -3123,8 +3112,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3123 GNUNET_asprintf (&arg, "%s:%s/blacklist", 3112 GNUNET_asprintf (&arg, "%s:%s/blacklist",
3124 pg->peers[pg_iter].daemon->hostname, 3113 pg->peers[pg_iter].daemon->hostname,
3125 temp_service_path); 3114 temp_service_path);
3126 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", 3115 procarr[pg_iter] =
3127 mytemp, arg, NULL); 3116 GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
3128 GNUNET_assert (procarr[pg_iter] != NULL); 3117 GNUNET_assert (procarr[pg_iter] != NULL);
3129 GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */ 3118 GNUNET_OS_process_wait (procarr[pg_iter]); /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */
3130 3119
@@ -3151,8 +3140,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3151#endif 3140#endif
3152 if (procarr[pg_iter] != NULL) /* Check for already completed! */ 3141 if (procarr[pg_iter] != NULL) /* Check for already completed! */
3153 { 3142 {
3154 if (GNUNET_OS_process_status (procarr[pg_iter], &type, 3143 if (GNUNET_OS_process_status (procarr[pg_iter], &type, &return_code) !=
3155 &return_code) != GNUNET_OK) 3144 GNUNET_OK)
3156 { 3145 {
3157 ret = GNUNET_SYSERR; 3146 ret = GNUNET_SYSERR;
3158 } 3147 }
@@ -3187,8 +3176,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
3187} 3176}
3188 3177
3189/* Forward Declaration */ 3178/* Forward Declaration */
3190static void 3179static void schedule_connect (void *cls,
3191schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 3180 const struct GNUNET_SCHEDULER_TaskContext *tc);
3192 3181
3193/** 3182/**
3194 * Choose a random peer's next connection to create, and 3183 * Choose a random peer's next connection to create, and
@@ -3206,11 +3195,11 @@ preschedule_connect (struct GNUNET_TESTING_PeerGroup *pg)
3206 3195
3207 if (ct_ctx->remaining_connections == 0) 3196 if (ct_ctx->remaining_connections == 0)
3208 return; 3197 return;
3209 random_peer 3198 random_peer =
3210 = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total); 3199 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
3211 while (pg->peers[random_peer].connect_peers_head == NULL) 3200 while (pg->peers[random_peer].connect_peers_head == NULL)
3212 random_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 3201 random_peer =
3213 pg->total); 3202 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, pg->total);
3214 3203
3215 connection_iter = pg->peers[random_peer].connect_peers_head; 3204 connection_iter = pg->peers[random_peer].connect_peers_head;
3216 connect_context = GNUNET_malloc (sizeof (struct ConnectContext)); 3205 connect_context = GNUNET_malloc (sizeof (struct ConnectContext));
@@ -3330,19 +3319,19 @@ send_core_connect_requests (void *cls,
3330 conn = send_hello_context->peer->connect_peers_head; 3319 conn = send_hello_context->peer->connect_peers_head;
3331 while (conn != NULL) 3320 while (conn != NULL)
3332 { 3321 {
3333 GNUNET_CORE_peer_request_connect (send_hello_context->peer-> 3322 GNUNET_CORE_peer_request_connect (send_hello_context->peer->daemon->
3334 daemon->server, 3323 server,
3335 &send_hello_context->pg-> 3324 &send_hello_context->pg->peers[conn->
3336 peers[conn->index].daemon->id, NULL, 3325 index].
3337 NULL); 3326 daemon->id, NULL, NULL);
3338 conn = conn->next; 3327 conn = conn->next;
3339 } 3328 }
3340 send_hello_context->core_connect_task = 3329 send_hello_context->core_connect_task =
3341 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3330 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3342 (send_hello_context->pg-> 3331 (send_hello_context->pg->ct_ctx.
3343 ct_ctx.connect_timeout, 3332 connect_timeout,
3344 send_hello_context->pg-> 3333 send_hello_context->pg->ct_ctx.
3345 ct_ctx.connect_attempts), 3334 connect_attempts),
3346 &send_core_connect_requests, 3335 &send_core_connect_requests,
3347 send_hello_context); 3336 send_hello_context);
3348 } 3337 }
@@ -3368,8 +3357,7 @@ send_core_connect_requests (void *cls,
3368 * doesn't take too long! 3357 * doesn't take too long!
3369 */ 3358 */
3370static void 3359static void
3371core_connect_notify (void *cls, 3360core_connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
3372 const struct GNUNET_PeerIdentity *peer,
3373 const struct GNUNET_TRANSPORT_ATS_Information *atsi) 3361 const struct GNUNET_TRANSPORT_ATS_Information *atsi)
3374{ 3362{
3375 struct SendHelloContext *send_hello_context = cls; 3363 struct SendHelloContext *send_hello_context = cls;
@@ -3380,8 +3368,7 @@ core_connect_notify (void *cls,
3380 struct PeerData *other_peer; 3368 struct PeerData *other_peer;
3381#endif 3369#endif
3382#if DEBUG_TESTING 3370#if DEBUG_TESTING
3383 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3371 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Connected peer %s to peer %s\n",
3384 "Connected peer %s to peer %s\n",
3385 ctx->d1->shortname, GNUNET_i2s (peer)); 3372 ctx->d1->shortname, GNUNET_i2s (peer));
3386#endif 3373#endif
3387 3374
@@ -3474,8 +3461,7 @@ core_connect_notify (void *cls,
3474 * @param publicKey the public key of the peer 3461 * @param publicKey the public key of the peer
3475 */ 3462 */
3476void 3463void
3477core_init (void *cls, 3464core_init (void *cls, struct GNUNET_CORE_Handle *server,
3478 struct GNUNET_CORE_Handle *server,
3479 const struct GNUNET_PeerIdentity *my_identity, 3465 const struct GNUNET_PeerIdentity *my_identity,
3480 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) 3466 const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey)
3481{ 3467{
@@ -3536,10 +3522,10 @@ hello_sent_callback (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3536 3522
3537 send_hello_context->core_connect_task = 3523 send_hello_context->core_connect_task =
3538 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide 3524 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_divide
3539 (send_hello_context->pg-> 3525 (send_hello_context->pg->ct_ctx.
3540 ct_ctx.connect_timeout, 3526 connect_timeout,
3541 send_hello_context->pg-> 3527 send_hello_context->pg->ct_ctx.
3542 ct_ctx.connect_attempts), 3528 connect_attempts),
3543 &send_core_connect_requests, 3529 &send_core_connect_requests,
3544 send_hello_context); 3530 send_hello_context);
3545 } 3531 }
@@ -3590,22 +3576,22 @@ schedule_send_hellos (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3590 if (send_hello_context->peer->daemon->th == NULL) 3576 if (send_hello_context->peer->daemon->th == NULL)
3591 { 3577 {
3592 pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */ 3578 pg->outstanding_connects++; /* Actual TRANSPORT, CORE connections! */
3593 send_hello_context->peer->daemon->th 3579 send_hello_context->peer->daemon->th =
3594 = GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL, 3580 GNUNET_TRANSPORT_connect (send_hello_context->peer->cfg, NULL,
3595 send_hello_context, NULL, NULL, NULL); 3581 send_hello_context, NULL, NULL, NULL);
3596 } 3582 }
3597#if DEBUG_TESTING 3583#if DEBUG_TESTING
3598 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3584 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3599 _("Offering Hello of peer %s to peer %s\n"), 3585 _("Offering Hello of peer %s to peer %s\n"),
3600 send_hello_context->peer->daemon->shortname, 3586 send_hello_context->peer->daemon->shortname,
3601 pg->peers[send_hello_context->peer_pos->index]. 3587 pg->peers[send_hello_context->peer_pos->index].daemon->
3602 daemon->shortname); 3588 shortname);
3603#endif 3589#endif
3604 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th, 3590 GNUNET_TRANSPORT_offer_hello (send_hello_context->peer->daemon->th,
3605 (const struct GNUNET_MessageHeader *) 3591 (const struct GNUNET_MessageHeader *) pg->
3606 pg->peers[send_hello_context->peer_pos-> 3592 peers[send_hello_context->peer_pos->index].
3607 index].daemon->hello, 3593 daemon->hello, &hello_sent_callback,
3608 &hello_sent_callback, send_hello_context); 3594 send_hello_context);
3609 send_hello_context->peer_pos = send_hello_context->peer_pos->next; 3595 send_hello_context->peer_pos = send_hello_context->peer_pos->next;
3610 GNUNET_assert (send_hello_context->peer->daemon->th != NULL); 3596 GNUNET_assert (send_hello_context->peer->daemon->th != NULL);
3611 } 3597 }
@@ -3644,12 +3630,10 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first,
3644 other_peer = NULL; 3630 other_peer = NULL;
3645#endif 3631#endif
3646 3632
3647 while ((connection != NULL) && (0 3633 while ((connection != NULL) &&
3648 != memcmp (first, 3634 (0 !=
3649 &pg->peers[connection-> 3635 memcmp (first, &pg->peers[connection->index].daemon->id,
3650 index].daemon->id, 3636 sizeof (struct GNUNET_PeerIdentity))))
3651 sizeof (struct
3652 GNUNET_PeerIdentity))))
3653 { 3637 {
3654 connection = connection->next; 3638 connection = connection->next;
3655 } 3639 }
@@ -3659,16 +3643,14 @@ internal_connect_notify (void *cls, const struct GNUNET_PeerIdentity *first,
3659 GNUNET_assert (0 < ct_ctx->remaining_connections); 3643 GNUNET_assert (0 < ct_ctx->remaining_connections);
3660 ct_ctx->remaining_connections--; 3644 ct_ctx->remaining_connections--;
3661 if (pg->notify_connection != NULL) /* Notify of reverse connection */ 3645 if (pg->notify_connection != NULL) /* Notify of reverse connection */
3662 pg->notify_connection (pg->notify_connection_cls, second, first, 3646 pg->notify_connection (pg->notify_connection_cls, second, first, distance,
3663 distance, second_cfg, first_cfg, second_daemon, 3647 second_cfg, first_cfg, second_daemon, first_daemon,
3664 first_daemon, emsg); 3648 emsg);
3665 3649
3666 GNUNET_CONTAINER_DLL_remove (pg-> 3650 GNUNET_CONTAINER_DLL_remove (pg->peers[connect_ctx->second_index].
3667 peers[connect_ctx-> 3651 connect_peers_head,
3668 second_index].connect_peers_head, 3652 pg->peers[connect_ctx->second_index].
3669 pg->peers[connect_ctx-> 3653 connect_peers_tail, connection);
3670 second_index].connect_peers_tail,
3671 connection);
3672 GNUNET_free (connection); 3654 GNUNET_free (connection);
3673 } 3655 }
3674 3656
@@ -3707,8 +3689,8 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3707 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 3689 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
3708 return; 3690 return;
3709 3691
3710 if ((pg->outstanding_connects > pg->max_outstanding_connections) 3692 if ((pg->outstanding_connects > pg->max_outstanding_connections) ||
3711 || (pg->stop_connects == GNUNET_YES)) 3693 (pg->stop_connects == GNUNET_YES))
3712 { 3694 {
3713#if VERBOSE_TESTING 3695#if VERBOSE_TESTING
3714 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3696 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -3729,10 +3711,10 @@ schedule_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
3729#endif 3711#endif
3730 pg->outstanding_connects++; 3712 pg->outstanding_connects++;
3731 pg->total_connects_scheduled++; 3713 pg->total_connects_scheduled++;
3732 GNUNET_TESTING_daemons_connect (pg-> 3714 GNUNET_TESTING_daemons_connect (pg->peers[connect_context->first_index].
3733 peers[connect_context->first_index].daemon, 3715 daemon,
3734 pg->peers[connect_context-> 3716 pg->peers[connect_context->second_index].
3735 second_index].daemon, 3717 daemon,
3736 connect_context->ct_ctx->connect_timeout, 3718 connect_context->ct_ctx->connect_timeout,
3737 connect_context->ct_ctx->connect_attempts, 3719 connect_context->ct_ctx->connect_attempts,
3738#if USE_SEND_HELLOS 3720#if USE_SEND_HELLOS
@@ -4032,11 +4014,11 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4032#if VERBOSE_TESTING 4014#if VERBOSE_TESTING
4033 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n")); 4015 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Creating topology from file!\n"));
4034#endif 4016#endif
4035 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing", 4017 if (GNUNET_OK ==
4036 "topology_file", 4018 GNUNET_CONFIGURATION_get_value_string (pg->cfg, "testing",
4037 &filename)) 4019 "topology_file", &filename))
4038 num_connections = create_from_file (pg, filename, &add_connections, 4020 num_connections =
4039 ALLOWED); 4021 create_from_file (pg, filename, &add_connections, ALLOWED);
4040 else 4022 else
4041 { 4023 {
4042 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4024 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -4057,8 +4039,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4057 break; 4039 break;
4058 } 4040 }
4059 4041
4060 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", 4042 if (GNUNET_YES ==
4061 "F2F")) 4043 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "F2F"))
4062 { 4044 {
4063 ret = create_and_copy_friend_files (pg); 4045 ret = create_and_copy_friend_files (pg);
4064 if (ret != GNUNET_OK) 4046 if (ret != GNUNET_OK)
@@ -4079,9 +4061,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4079 } 4061 }
4080 4062
4081 /* Use the create clique method to initially set all connections as blacklisted. */ 4063 /* Use the create clique method to initially set all connections as blacklisted. */
4082 if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) && (restrict_topology 4064 if ((restrict_topology != GNUNET_TESTING_TOPOLOGY_NONE) &&
4083 != 4065 (restrict_topology != GNUNET_TESTING_TOPOLOGY_FROM_FILE))
4084 GNUNET_TESTING_TOPOLOGY_FROM_FILE))
4085 create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO); 4066 create_clique (pg, &add_connections, BLACKLIST, GNUNET_NO);
4086 else 4067 else
4087 return num_connections; 4068 return num_connections;
@@ -4095,49 +4076,48 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4095 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4076 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4096 _("Blacklisting all but clique topology\n")); 4077 _("Blacklisting all but clique topology\n"));
4097#endif 4078#endif
4098 unblacklisted_connections = create_clique (pg, &remove_connections, 4079 unblacklisted_connections =
4099 BLACKLIST, GNUNET_NO); 4080 create_clique (pg, &remove_connections, BLACKLIST, GNUNET_NO);
4100 break; 4081 break;
4101 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING: 4082 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD_RING:
4102#if VERBOSE_TESTING 4083#if VERBOSE_TESTING
4103 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4084 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4104 _("Blacklisting all but small world (ring) topology\n")); 4085 _("Blacklisting all but small world (ring) topology\n"));
4105#endif 4086#endif
4106 unblacklisted_connections = create_small_world_ring (pg, 4087 unblacklisted_connections =
4107 &remove_connections, 4088 create_small_world_ring (pg, &remove_connections, BLACKLIST);
4108 BLACKLIST);
4109 break; 4089 break;
4110 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD: 4090 case GNUNET_TESTING_TOPOLOGY_SMALL_WORLD:
4111#if VERBOSE_TESTING 4091#if VERBOSE_TESTING
4112 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4092 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4113 _("Blacklisting all but small world (2d-torus) topology\n")); 4093 _("Blacklisting all but small world (2d-torus) topology\n"));
4114#endif 4094#endif
4115 unblacklisted_connections = create_small_world (pg, &remove_connections, 4095 unblacklisted_connections =
4116 BLACKLIST); 4096 create_small_world (pg, &remove_connections, BLACKLIST);
4117 break; 4097 break;
4118 case GNUNET_TESTING_TOPOLOGY_RING: 4098 case GNUNET_TESTING_TOPOLOGY_RING:
4119#if VERBOSE_TESTING 4099#if VERBOSE_TESTING
4120 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4100 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4121 _("Blacklisting all but ring topology\n")); 4101 _("Blacklisting all but ring topology\n"));
4122#endif 4102#endif
4123 unblacklisted_connections 4103 unblacklisted_connections =
4124 = create_ring (pg, &remove_connections, BLACKLIST); 4104 create_ring (pg, &remove_connections, BLACKLIST);
4125 break; 4105 break;
4126 case GNUNET_TESTING_TOPOLOGY_2D_TORUS: 4106 case GNUNET_TESTING_TOPOLOGY_2D_TORUS:
4127#if VERBOSE_TESTING 4107#if VERBOSE_TESTING
4128 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4108 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4129 _("Blacklisting all but 2d torus topology\n")); 4109 _("Blacklisting all but 2d torus topology\n"));
4130#endif 4110#endif
4131 unblacklisted_connections = create_2d_torus (pg, &remove_connections, 4111 unblacklisted_connections =
4132 BLACKLIST); 4112 create_2d_torus (pg, &remove_connections, BLACKLIST);
4133 break; 4113 break;
4134 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI: 4114 case GNUNET_TESTING_TOPOLOGY_ERDOS_RENYI:
4135#if VERBOSE_TESTING 4115#if VERBOSE_TESTING
4136 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4116 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4137 _("Blacklisting all but Erdos-Renyi topology\n")); 4117 _("Blacklisting all but Erdos-Renyi topology\n"));
4138#endif 4118#endif
4139 unblacklisted_connections = create_erdos_renyi (pg, &remove_connections, 4119 unblacklisted_connections =
4140 BLACKLIST); 4120 create_erdos_renyi (pg, &remove_connections, BLACKLIST);
4141 break; 4121 break;
4142 case GNUNET_TESTING_TOPOLOGY_INTERNAT: 4122 case GNUNET_TESTING_TOPOLOGY_INTERNAT:
4143#if VERBOSE_TESTING 4123#if VERBOSE_TESTING
@@ -4168,8 +4148,8 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4168 pg->peers[off].connect_peers_head = NULL; 4148 pg->peers[off].connect_peers_head = NULL;
4169 pg->peers[off].connect_peers_tail = NULL; 4149 pg->peers[off].connect_peers_tail = NULL;
4170 } 4150 }
4171 unblacklisted_connections 4151 unblacklisted_connections =
4172 = create_nated_internet_copy (pg, &remove_connections, BLACKLIST); 4152 create_nated_internet_copy (pg, &remove_connections, BLACKLIST);
4173#else 4153#else
4174 unblacklisted_connections = 4154 unblacklisted_connections =
4175 create_nated_internet (pg, &remove_connections, BLACKLIST); 4155 create_nated_internet (pg, &remove_connections, BLACKLIST);
@@ -4181,16 +4161,16 @@ GNUNET_TESTING_create_topology (struct GNUNET_TESTING_PeerGroup *pg,
4181 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4161 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4182 _("Blacklisting all but Scale Free topology\n")); 4162 _("Blacklisting all but Scale Free topology\n"));
4183#endif 4163#endif
4184 unblacklisted_connections = create_scale_free (pg, &remove_connections, 4164 unblacklisted_connections =
4185 BLACKLIST); 4165 create_scale_free (pg, &remove_connections, BLACKLIST);
4186 break; 4166 break;
4187 case GNUNET_TESTING_TOPOLOGY_LINE: 4167 case GNUNET_TESTING_TOPOLOGY_LINE:
4188#if VERBOSE_TESTING 4168#if VERBOSE_TESTING
4189 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4169 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4190 _("Blacklisting all but straight line topology\n")); 4170 _("Blacklisting all but straight line topology\n"));
4191#endif 4171#endif
4192 unblacklisted_connections 4172 unblacklisted_connections =
4193 = create_line (pg, &remove_connections, BLACKLIST); 4173 create_line (pg, &remove_connections, BLACKLIST);
4194 default: 4174 default:
4195 break; 4175 break;
4196 } 4176 }
@@ -4244,8 +4224,8 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4244 if (random_number < random_ctx->percentage) 4224 if (random_number < random_ctx->percentage)
4245 { 4225 {
4246 GNUNET_assert (GNUNET_OK == 4226 GNUNET_assert (GNUNET_OK ==
4247 GNUNET_CONTAINER_multihashmap_put (random_ctx-> 4227 GNUNET_CONTAINER_multihashmap_put (random_ctx->first->
4248 first->connect_peers_working_set, 4228 connect_peers_working_set,
4249 key, value, 4229 key, value,
4250 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4230 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4251 } 4231 }
@@ -4255,11 +4235,12 @@ random_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4255 hash_from_uid (random_ctx->first_uid, &first_hash); 4235 hash_from_uid (random_ctx->first_uid, &first_hash);
4256 GNUNET_assert (random_ctx->pg->total > second_pos); 4236 GNUNET_assert (random_ctx->pg->total > second_pos);
4257 GNUNET_assert (GNUNET_YES == 4237 GNUNET_assert (GNUNET_YES ==
4258 GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->peers 4238 GNUNET_CONTAINER_multihashmap_remove (random_ctx->pg->
4259 [second_pos].connect_peers, 4239 peers[second_pos].
4240 connect_peers,
4260 &first_hash, 4241 &first_hash,
4261 random_ctx-> 4242 random_ctx->first->
4262 first->daemon)); 4243 daemon));
4263 4244
4264 return GNUNET_YES; 4245 return GNUNET_YES;
4265} 4246}
@@ -4289,25 +4270,29 @@ minimum_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4289 if (min_ctx->pg_array[i] == min_ctx->current) 4270 if (min_ctx->pg_array[i] == min_ctx->current)
4290 { 4271 {
4291 GNUNET_assert (GNUNET_OK == 4272 GNUNET_assert (GNUNET_OK ==
4292 GNUNET_CONTAINER_multihashmap_put 4273 GNUNET_CONTAINER_multihashmap_put (min_ctx->first->
4293 (min_ctx->first->connect_peers_working_set, key, 4274 connect_peers_working_set,
4294 value, 4275 key, value,
4295 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4276 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4296 uid_from_hash (key, &second_pos); 4277 uid_from_hash (key, &second_pos);
4297 hash_from_uid (min_ctx->first_uid, &first_hash); 4278 hash_from_uid (min_ctx->first_uid, &first_hash);
4298 GNUNET_assert (min_ctx->pg->total > second_pos); 4279 GNUNET_assert (min_ctx->pg->total > second_pos);
4299 GNUNET_assert (GNUNET_OK == 4280 GNUNET_assert (GNUNET_OK ==
4300 GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->peers 4281 GNUNET_CONTAINER_multihashmap_put (min_ctx->pg->
4301 [second_pos].connect_peers_working_set, 4282 peers[second_pos].
4283 connect_peers_working_set,
4302 &first_hash, 4284 &first_hash,
4303 min_ctx->first-> 4285 min_ctx->
4304 daemon, 4286 first->daemon,
4305 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4287 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4306 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */ 4288 /* Now we have added this particular connection, remove it from the second peer's map so it's not double counted */
4307 GNUNET_assert (GNUNET_YES == 4289 GNUNET_assert (GNUNET_YES ==
4308 GNUNET_CONTAINER_multihashmap_remove 4290 GNUNET_CONTAINER_multihashmap_remove (min_ctx->pg->
4309 (min_ctx->pg->peers[second_pos].connect_peers, 4291 peers[second_pos].
4310 &first_hash, min_ctx->first->daemon)); 4292 connect_peers,
4293 &first_hash,
4294 min_ctx->first->
4295 daemon));
4311 } 4296 }
4312 } 4297 }
4313 min_ctx->current++; 4298 min_ctx->current++;
@@ -4336,26 +4321,28 @@ dfs_connect_iterator (void *cls, const GNUNET_HashCode * key, void *value)
4336 if (dfs_ctx->current == dfs_ctx->chosen) 4321 if (dfs_ctx->current == dfs_ctx->chosen)
4337 { 4322 {
4338 GNUNET_assert (GNUNET_OK == 4323 GNUNET_assert (GNUNET_OK ==
4339 GNUNET_CONTAINER_multihashmap_put (dfs_ctx-> 4324 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->first->
4340 first->connect_peers_working_set, 4325 connect_peers_working_set,
4341 key, value, 4326 key, value,
4342 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4327 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4343 uid_from_hash (key, &dfs_ctx->second_uid); 4328 uid_from_hash (key, &dfs_ctx->second_uid);
4344 hash_from_uid (dfs_ctx->first_uid, &first_hash); 4329 hash_from_uid (dfs_ctx->first_uid, &first_hash);
4345 GNUNET_assert (GNUNET_OK == 4330 GNUNET_assert (GNUNET_OK ==
4346 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->peers 4331 GNUNET_CONTAINER_multihashmap_put (dfs_ctx->pg->
4347 [dfs_ctx-> 4332 peers
4348 second_uid].connect_peers_working_set, 4333 [dfs_ctx->second_uid].
4334 connect_peers_working_set,
4349 &first_hash, 4335 &first_hash,
4350 dfs_ctx->first->daemon, 4336 dfs_ctx->first->daemon,
4351 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); 4337 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
4352 GNUNET_assert (GNUNET_YES == 4338 GNUNET_assert (GNUNET_YES ==
4353 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx-> 4339 GNUNET_CONTAINER_multihashmap_remove (dfs_ctx->pg->
4354 pg->peers 4340 peers[dfs_ctx->
4355 [dfs_ctx->second_uid].connect_peers, 4341 second_uid].
4342 connect_peers,
4356 &first_hash, 4343 &first_hash,
4357 dfs_ctx-> 4344 dfs_ctx->first->
4358 first->daemon)); 4345 daemon));
4359 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */ 4346 /* Can't remove second from first yet because we are currently iterating, hence the return value in the DFSContext! */
4360 return GNUNET_NO; /* We have found our peer, don't iterate more */ 4347 return GNUNET_NO; /* We have found our peer, don't iterate more */
4361 } 4348 }
@@ -4391,10 +4378,10 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4391 conn_iter = pg->peers[pg_iter].connect_peers_head; 4378 conn_iter = pg->peers[pg_iter].connect_peers_head;
4392 while (conn_iter != NULL) 4379 while (conn_iter != NULL)
4393 { 4380 {
4394 random_number 4381 random_number =
4395 = ((double) GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, 4382 ((double)
4396 UINT64_MAX)) 4383 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
4397 / ((double) UINT64_MAX); 4384 UINT64_MAX)) / ((double) UINT64_MAX);
4398 if (random_number < percentage) 4385 if (random_number < percentage)
4399 { 4386 {
4400 add_connections (pg, pg_iter, conn_iter->index, WORKING_SET, 4387 add_connections (pg, pg_iter, conn_iter->index, WORKING_SET,
@@ -4407,16 +4394,16 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4407 random_ctx.first = &pg->peers[pg_iter]; 4394 random_ctx.first = &pg->peers[pg_iter];
4408 random_ctx.percentage = percentage; 4395 random_ctx.percentage = percentage;
4409 random_ctx.pg = pg; 4396 random_ctx.pg = pg;
4410 pg->peers[pg_iter].connect_peers_working_set 4397 pg->peers[pg_iter].connect_peers_working_set =
4411 = GNUNET_CONTAINER_multihashmap_create (pg->total); 4398 GNUNET_CONTAINER_multihashmap_create (pg->total);
4412 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers, 4399 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[pg_iter].connect_peers,
4413 &random_connect_iterator, 4400 &random_connect_iterator,
4414 &random_ctx); 4401 &random_ctx);
4415 /* Now remove the old connections */ 4402 /* Now remove the old connections */
4416 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers); 4403 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[pg_iter].connect_peers);
4417 /* And replace with the random set */ 4404 /* And replace with the random set */
4418 pg->peers[pg_iter].connect_peers 4405 pg->peers[pg_iter].connect_peers =
4419 = pg->peers[pg_iter].connect_peers_working_set; 4406 pg->peers[pg_iter].connect_peers_working_set;
4420#endif 4407#endif
4421 } 4408 }
4422 4409
@@ -4425,13 +4412,13 @@ choose_random_connections (struct GNUNET_TESTING_PeerGroup *pg,
4425 conn_iter = pg->peers[pg_iter].connect_peers_head; 4412 conn_iter = pg->peers[pg_iter].connect_peers_head;
4426 while (pg->peers[pg_iter].connect_peers_head != NULL) 4413 while (pg->peers[pg_iter].connect_peers_head != NULL)
4427 remove_connections (pg, pg_iter, 4414 remove_connections (pg, pg_iter,
4428 pg->peers[pg_iter].connect_peers_head->index, 4415 pg->peers[pg_iter].connect_peers_head->index, CONNECT,
4429 CONNECT, GNUNET_YES); 4416 GNUNET_YES);
4430 4417
4431 pg->peers[pg_iter].connect_peers_head 4418 pg->peers[pg_iter].connect_peers_head =
4432 = pg->peers[pg_iter].connect_peers_working_set_head; 4419 pg->peers[pg_iter].connect_peers_working_set_head;
4433 pg->peers[pg_iter].connect_peers_tail 4420 pg->peers[pg_iter].connect_peers_tail =
4434 = pg->peers[pg_iter].connect_peers_working_set_tail; 4421 pg->peers[pg_iter].connect_peers_working_set_tail;
4435 pg->peers[pg_iter].connect_peers_working_set_head = NULL; 4422 pg->peers[pg_iter].connect_peers_working_set_head = NULL;
4436 pg->peers[pg_iter].connect_peers_working_set_tail = NULL; 4423 pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
4437 } 4424 }
@@ -4482,8 +4469,8 @@ count_workingset_connections (struct GNUNET_TESTING_PeerGroup *pg)
4482 } 4469 }
4483#else 4470#else
4484 count += 4471 count +=
4485 GNUNET_CONTAINER_multihashmap_size (pg->peers 4472 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter].
4486 [pg_iter].connect_peers_working_set); 4473 connect_peers_working_set);
4487#endif 4474#endif
4488 } 4475 }
4489 4476
@@ -4546,14 +4533,14 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4546 temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head); 4533 temp_list_size = count_connections (pg->peers[pg_iter].connect_peers_head);
4547 if (temp_list_size == 0) 4534 if (temp_list_size == 0)
4548 { 4535 {
4549 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 4536 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Peer %d has 0 connections!?!?\n",
4550 "Peer %d has 0 connections!?!?\n", pg_iter); 4537 pg_iter);
4551 break; 4538 break;
4552 } 4539 }
4553 for (i = 0; i < num; i++) 4540 for (i = 0; i < num; i++)
4554 { 4541 {
4555 random = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4542 random =
4556 temp_list_size); 4543 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_list_size);
4557 conn_iter = pg->peers[pg_iter].connect_peers_head; 4544 conn_iter = pg->peers[pg_iter].connect_peers_head;
4558 for (count = 0; count < random; count++) 4545 for (count = 0; count < random; count++)
4559 conn_iter = conn_iter->next; 4546 conn_iter = conn_iter->next;
@@ -4574,8 +4561,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4574 minimum_ctx.first_uid = pg_iter; 4561 minimum_ctx.first_uid = pg_iter;
4575 minimum_ctx.pg_array = 4562 minimum_ctx.pg_array =
4576 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 4563 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK,
4577 GNUNET_CONTAINER_multihashmap_size 4564 GNUNET_CONTAINER_multihashmap_size (pg->
4578 (pg->peers[pg_iter].connect_peers)); 4565 peers
4566 [pg_iter].
4567 connect_peers));
4579 minimum_ctx.first = &pg->peers[pg_iter]; 4568 minimum_ctx.first = &pg->peers[pg_iter];
4580 minimum_ctx.pg = pg; 4569 minimum_ctx.pg = pg;
4581 minimum_ctx.num_to_add = num; 4570 minimum_ctx.num_to_add = num;
@@ -4606,10 +4595,10 @@ choose_minimum (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4606 /*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */ 4595 /*remove_connections(pg, pg_iter, pg->peers[pg_iter].connect_peers_head->index, CONNECT, GNUNET_YES); */
4607 } 4596 }
4608 4597
4609 pg->peers[pg_iter].connect_peers_head 4598 pg->peers[pg_iter].connect_peers_head =
4610 = pg->peers[pg_iter].connect_peers_working_set_head; 4599 pg->peers[pg_iter].connect_peers_working_set_head;
4611 pg->peers[pg_iter].connect_peers_tail 4600 pg->peers[pg_iter].connect_peers_tail =
4612 = pg->peers[pg_iter].connect_peers_working_set_tail; 4601 pg->peers[pg_iter].connect_peers_working_set_tail;
4613 pg->peers[pg_iter].connect_peers_working_set_head = NULL; 4602 pg->peers[pg_iter].connect_peers_working_set_head = NULL;
4614 pg->peers[pg_iter].connect_peers_working_set_tail = NULL; 4603 pg->peers[pg_iter].connect_peers_working_set_tail = NULL;
4615 } 4604 }
@@ -4663,16 +4652,15 @@ find_closest_peers (void *cls, const GNUNET_HashCode * key, void *value)
4663 (GNUNET_CRYPTO_hash_matching_bits 4652 (GNUNET_CRYPTO_hash_matching_bits
4664 (&daemon->id.hashPubKey, 4653 (&daemon->id.hashPubKey,
4665 &closest_ctx->curr_peer->daemon->id.hashPubKey) > 4654 &closest_ctx->curr_peer->daemon->id.hashPubKey) >
4666 closest_ctx->closest_dist)) 4655 closest_ctx->closest_dist)) &&
4667 && (GNUNET_YES != 4656 (GNUNET_YES !=
4668 GNUNET_CONTAINER_multihashmap_contains (closest_ctx-> 4657 GNUNET_CONTAINER_multihashmap_contains (closest_ctx->curr_peer->
4669 curr_peer->connect_peers, 4658 connect_peers, key)))
4670 key)))
4671 { 4659 {
4672 closest_ctx->closest_dist = 4660 closest_ctx->closest_dist =
4673 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey, 4661 GNUNET_CRYPTO_hash_matching_bits (&daemon->id.hashPubKey,
4674 &closest_ctx->curr_peer->daemon-> 4662 &closest_ctx->curr_peer->daemon->id.
4675 id.hashPubKey); 4663 hashPubKey);
4676 closest_ctx->closest = daemon; 4664 closest_ctx->closest = daemon;
4677 uid_from_hash (key, &closest_ctx->closest_num); 4665 uid_from_hash (key, &closest_ctx->closest_num);
4678 } 4666 }
@@ -4750,18 +4738,17 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4750#if OLD 4738#if OLD
4751 starting_peer = 0; 4739 starting_peer = 0;
4752 dfs_count = 0; 4740 dfs_count = 0;
4753 while ((count_workingset_connections (pg) < num * pg->total) 4741 while ((count_workingset_connections (pg) < num * pg->total) &&
4754 && (count_allowed_connections (pg) > 0)) 4742 (count_allowed_connections (pg) > 0))
4755 { 4743 {
4756 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ 4744 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
4757 { 4745 {
4758 least_connections = -1; /* Set to very high number */ 4746 least_connections = -1; /* Set to very high number */
4759 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 4747 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
4760 { 4748 {
4761 temp_count 4749 temp_count =
4762 = 4750 count_connections (pg->peers[pg_iter].
4763 count_connections (pg-> 4751 connect_peers_working_set_head);
4764 peers[pg_iter].connect_peers_working_set_head);
4765 if (temp_count < least_connections) 4752 if (temp_count < least_connections)
4766 { 4753 {
4767 starting_peer = pg_iter; 4754 starting_peer = pg_iter;
@@ -4770,13 +4757,13 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4770 } 4757 }
4771 } 4758 }
4772 4759
4773 temp_count 4760 temp_count =
4774 = count_connections (pg->peers[starting_peer].connect_peers_head); 4761 count_connections (pg->peers[starting_peer].connect_peers_head);
4775 if (temp_count == 0) 4762 if (temp_count == 0)
4776 continue; /* FIXME: infinite loop? */ 4763 continue; /* FIXME: infinite loop? */
4777 4764
4778 random_connection = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4765 random_connection =
4779 temp_count); 4766 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, temp_count);
4780 temp_count = 0; 4767 temp_count = 0;
4781 peer_iter = pg->peers[starting_peer].connect_peers_head; 4768 peer_iter = pg->peers[starting_peer].connect_peers_head;
4782 while (temp_count < random_connection) 4769 while (temp_count < random_connection)
@@ -4802,8 +4789,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4802 4789
4803 starting_peer = 0; 4790 starting_peer = 0;
4804 dfs_count = 0; 4791 dfs_count = 0;
4805 while ((count_workingset_connections (pg) < num * pg->total) 4792 while ((count_workingset_connections (pg) < num * pg->total) &&
4806 && (count_allowed_connections (pg) > 0)) 4793 (count_allowed_connections (pg) > 0))
4807 { 4794 {
4808 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */ 4795 if (dfs_count % pg->total == 0) /* Restart the DFS at some weakly connected peer */
4809 { 4796 {
@@ -4815,8 +4802,8 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4815 { 4802 {
4816 starting_peer = pg_iter; 4803 starting_peer = pg_iter;
4817 least_connections = 4804 least_connections =
4818 GNUNET_CONTAINER_multihashmap_size (pg->peers 4805 GNUNET_CONTAINER_multihashmap_size (pg->peers[pg_iter].
4819 [pg_iter].connect_peers_working_set); 4806 connect_peers_working_set);
4820 } 4807 }
4821 } 4808 }
4822 } 4809 }
@@ -4830,25 +4817,28 @@ perform_dfs (struct GNUNET_TESTING_PeerGroup *pg, unsigned int num)
4830 /* Choose a random peer from the chosen peers set of connections to add */ 4817 /* Choose a random peer from the chosen peers set of connections to add */
4831 dfs_ctx.chosen = 4818 dfs_ctx.chosen =
4832 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 4819 GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
4833 GNUNET_CONTAINER_multihashmap_size 4820 GNUNET_CONTAINER_multihashmap_size (pg->
4834 (pg->peers[starting_peer].connect_peers)); 4821 peers
4822 [starting_peer].
4823 connect_peers));
4835 dfs_ctx.first_uid = starting_peer; 4824 dfs_ctx.first_uid = starting_peer;
4836 dfs_ctx.first = &pg->peers[starting_peer]; 4825 dfs_ctx.first = &pg->peers[starting_peer];
4837 dfs_ctx.pg = pg; 4826 dfs_ctx.pg = pg;
4838 dfs_ctx.current = 0; 4827 dfs_ctx.current = 0;
4839 4828
4840 GNUNET_CONTAINER_multihashmap_iterate (pg->peers 4829 GNUNET_CONTAINER_multihashmap_iterate (pg->peers[starting_peer].
4841 [starting_peer].connect_peers, 4830 connect_peers, &dfs_connect_iterator,
4842 &dfs_connect_iterator, &dfs_ctx); 4831 &dfs_ctx);
4843 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */ 4832 /* Remove the second from the first, since we will be continuing the search and may encounter the first peer again! */
4844 hash_from_uid (dfs_ctx.second_uid, &second_hash); 4833 hash_from_uid (dfs_ctx.second_uid, &second_hash);
4845 GNUNET_assert (GNUNET_YES == 4834 GNUNET_assert (GNUNET_YES ==
4846 GNUNET_CONTAINER_multihashmap_remove (pg->peers 4835 GNUNET_CONTAINER_multihashmap_remove (pg->
4847 [starting_peer].connect_peers, 4836 peers[starting_peer].
4837 connect_peers,
4848 &second_hash, 4838 &second_hash,
4849 pg-> 4839 pg->peers[dfs_ctx.
4850 peers 4840 second_uid].
4851 [dfs_ctx.second_uid].daemon)); 4841 daemon));
4852 starting_peer = dfs_ctx.second_uid; 4842 starting_peer = dfs_ctx.second_uid;
4853 } 4843 }
4854 4844
@@ -4906,8 +4896,8 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4906 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0) 4896 if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
4907 return; 4897 return;
4908 4898
4909 if (topology_context->connected 4899 if (topology_context->connected >
4910 > topology_context->pg->max_outstanding_connections) 4900 topology_context->pg->max_outstanding_connections)
4911 { 4901 {
4912#if VERBOSE_TESTING > 2 4902#if VERBOSE_TESTING > 2
4913 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4903 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -4927,9 +4917,9 @@ schedule_get_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
4927#endif 4917#endif
4928 topology_context->connected++; 4918 topology_context->connected++;
4929 4919
4930 if (GNUNET_OK != GNUNET_CORE_iterate_peers (core_context->daemon->cfg, 4920 if (GNUNET_OK !=
4931 &internal_topology_callback, 4921 GNUNET_CORE_iterate_peers (core_context->daemon->cfg,
4932 core_context)) 4922 &internal_topology_callback, core_context))
4933 { 4923 {
4934 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n"); 4924 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Topology iteration failed.\n");
4935 internal_topology_callback (core_context, NULL, NULL); 4925 internal_topology_callback (core_context, NULL, NULL);
@@ -5068,19 +5058,19 @@ schedule_get_statistics (void *cls,
5068#endif 5058#endif
5069 5059
5070 stats_context->connected++; 5060 stats_context->connected++;
5071 core_context->stats_handle 5061 core_context->stats_handle =
5072 = GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg); 5062 GNUNET_STATISTICS_create ("testing", core_context->daemon->cfg);
5073 if (core_context->stats_handle == NULL) 5063 if (core_context->stats_handle == NULL)
5074 { 5064 {
5075 internal_stats_cont (core_context, GNUNET_NO); 5065 internal_stats_cont (core_context, GNUNET_NO);
5076 return; 5066 return;
5077 } 5067 }
5078 5068
5079 core_context->stats_get_handle 5069 core_context->stats_get_handle =
5080 = GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL, 5070 GNUNET_STATISTICS_get (core_context->stats_handle, NULL, NULL,
5081 GNUNET_TIME_relative_get_forever (), 5071 GNUNET_TIME_relative_get_forever (),
5082 &internal_stats_cont, 5072 &internal_stats_cont, &internal_stats_callback,
5083 &internal_stats_callback, core_context); 5073 core_context);
5084 if (core_context->stats_get_handle == NULL) 5074 if (core_context->stats_get_handle == NULL)
5085 internal_stats_cont (core_context, GNUNET_NO); 5075 internal_stats_cont (core_context, GNUNET_NO);
5086 5076
@@ -5121,21 +5111,20 @@ stats_check_existing (struct GNUNET_TESTING_PeerGroup *pg,
5121 unsigned long long port; 5111 unsigned long long port;
5122 char *to_match; 5112 char *to_match;
5123 5113
5124 if (GNUNET_YES 5114 if (GNUNET_YES !=
5125 != GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing", 5115 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "testing",
5126 "single_statistics_per_host")) 5116 "single_statistics_per_host"))
5127 return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */ 5117 return GNUNET_NO; /* Each peer has its own statistics instance, do nothing! */
5128 5118
5129 pos = *stats_list; 5119 pos = *stats_list;
5130 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, 5120 if (GNUNET_OK !=
5131 "statistics", 5121 GNUNET_CONFIGURATION_get_value_string (specific_peer->cfg, "statistics",
5132 "unixpath", 5122 "unixpath", &unix_domain_socket))
5133 &unix_domain_socket))
5134 return GNUNET_NO; 5123 return GNUNET_NO;
5135 5124
5136 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, 5125 if (GNUNET_OK !=
5137 "statistics", "port", 5126 GNUNET_CONFIGURATION_get_value_number (specific_peer->cfg, "statistics",
5138 &port)) 5127 "port", &port))
5139 { 5128 {
5140 GNUNET_free (unix_domain_socket); 5129 GNUNET_free (unix_domain_socket);
5141 return GNUNET_NO; 5130 return GNUNET_NO;
@@ -5200,11 +5189,8 @@ GNUNET_TESTING_get_statistics (struct GNUNET_TESTING_PeerGroup *pg,
5200 5189
5201 for (i = 0; i < pg->total; i++) 5190 for (i = 0; i < pg->total; i++)
5202 { 5191 {
5203 if ((pg->peers[i].daemon->running == GNUNET_YES) && (GNUNET_NO 5192 if ((pg->peers[i].daemon->running == GNUNET_YES) &&
5204 == 5193 (GNUNET_NO == stats_check_existing (pg, &pg->peers[i], &stats_list)))
5205 stats_check_existing
5206 (pg, &pg->peers[i],
5207 &stats_list)))
5208 { 5194 {
5209 /* Allocate one core context per core we need to connect to */ 5195 /* Allocate one core context per core we need to connect to */
5210 core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext)); 5196 core_ctx = GNUNET_malloc (sizeof (struct StatsCoreContext));
@@ -5358,8 +5344,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5358 copy_allowed_topology (pg); 5344 copy_allowed_topology (pg);
5359 break; 5345 break;
5360 default: 5346 default:
5361 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ 5347 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5362 ("Unknown topology specification, can't connect peers!\n")); 5348 _("Unknown topology specification, can't connect peers!\n"));
5363 return GNUNET_SYSERR; 5349 return GNUNET_SYSERR;
5364 } 5350 }
5365 5351
@@ -5367,7 +5353,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5367 { 5353 {
5368 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM: 5354 case GNUNET_TESTING_TOPOLOGY_OPTION_RANDOM:
5369#if VERBOSE_TOPOLOGY 5355#if VERBOSE_TOPOLOGY
5370 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ 5356 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5357 _
5371 ("Connecting random subset (%'.2f percent) of possible peers\n"), 5358 ("Connecting random subset (%'.2f percent) of possible peers\n"),
5372 100 * option_modifier); 5359 100 * option_modifier);
5373#endif 5360#endif
@@ -5383,7 +5370,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5383 break; 5370 break;
5384 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS: 5371 case GNUNET_TESTING_TOPOLOGY_OPTION_DFS:
5385#if VERBOSE_TOPOLOGY 5372#if VERBOSE_TOPOLOGY
5386 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ 5373 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5374 _
5387 ("Using DFS to connect a minimum of %u peers each (if possible)\n"), 5375 ("Using DFS to connect a minimum of %u peers each (if possible)\n"),
5388 (unsigned int) option_modifier); 5376 (unsigned int) option_modifier);
5389#endif 5377#endif
@@ -5393,8 +5381,8 @@ GNUNET_TESTING_connect_topology (struct GNUNET_TESTING_PeerGroup *pg,
5393 break; 5381 break;
5394 case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST: 5382 case GNUNET_TESTING_TOPOLOGY_OPTION_ADD_CLOSEST:
5395#if VERBOSE_TOPOLOGY 5383#if VERBOSE_TOPOLOGY
5396 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _ 5384 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5397 ("Finding additional %u closest peers each (if possible)\n"), 5385 _("Finding additional %u closest peers each (if possible)\n"),
5398 (unsigned int) option_modifier); 5386 (unsigned int) option_modifier);
5399#endif 5387#endif
5400#if FIXME 5388#if FIXME
@@ -5498,8 +5486,8 @@ internal_hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5498 if (internal_context->hostkey_callback != NULL) 5486 if (internal_context->hostkey_callback != NULL)
5499 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d, 5487 internal_context->hostkey_callback (internal_context->hostkey_cls, id, d,
5500 emsg); 5488 emsg);
5501 else if (internal_context->peer->pg->started 5489 else if (internal_context->peer->pg->started ==
5502 == internal_context->peer->pg->total) 5490 internal_context->peer->pg->total)
5503 { 5491 {
5504 internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */ 5492 internal_context->peer->pg->started = 0; /* Internal startup may use this counter! */
5505 GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg); 5493 GNUNET_TESTING_daemons_continue_startup (internal_context->peer->pg);
@@ -5544,12 +5532,13 @@ internal_continue_startup (void *cls,
5544 return; 5532 return;
5545 } 5533 }
5546 5534
5547 if ((internal_context->peer->pg->starting 5535 if ((internal_context->peer->pg->starting <
5548 < internal_context->peer->pg->max_concurrent_ssh) 5536 internal_context->peer->pg->max_concurrent_ssh) ||
5549 || ((internal_context->hostname != NULL) 5537 ((internal_context->hostname != NULL) &&
5550 && (count_outstanding_at_host (internal_context->hostname, 5538 (count_outstanding_at_host
5551 internal_context->peer->pg) 5539 (internal_context->hostname,
5552 < internal_context->peer->pg->max_concurrent_ssh))) 5540 internal_context->peer->pg) <
5541 internal_context->peer->pg->max_concurrent_ssh)))
5553 { 5542 {
5554 if (internal_context->hostname != NULL) 5543 if (internal_context->hostname != NULL)
5555 increment_outstanding_at_host (internal_context->hostname, 5544 increment_outstanding_at_host (internal_context->hostname,
@@ -5599,8 +5588,9 @@ churn_start_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5599 churn_ctx->num_to_start--; 5588 churn_ctx->num_to_start--;
5600 } 5589 }
5601 5590
5602 total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) 5591 total_left =
5603 + (churn_ctx->num_to_start - churn_ctx->num_failed_start); 5592 (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
5593 (churn_ctx->num_to_start - churn_ctx->num_failed_start);
5604 5594
5605 if (total_left == 0) 5595 if (total_left == 0)
5606 { 5596 {
@@ -5630,8 +5620,8 @@ schedule_churn_restart (void *cls,
5630 { 5620 {
5631 if (startup_ctx->churn_ctx->service != NULL) 5621 if (startup_ctx->churn_ctx->service != NULL)
5632 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon, 5622 GNUNET_TESTING_daemon_start_stopped_service (peer_restart_ctx->daemon,
5633 startup_ctx-> 5623 startup_ctx->churn_ctx->
5634 churn_ctx->service, 5624 service,
5635 startup_ctx->timeout, 5625 startup_ctx->timeout,
5636 &churn_start_callback, 5626 &churn_start_callback,
5637 startup_ctx); 5627 startup_ctx);
@@ -5655,8 +5645,7 @@ schedule_churn_restart (void *cls,
5655 * 5645 *
5656 */ 5646 */
5657void 5647void
5658service_start_callback (void *cls, 5648service_start_callback (void *cls, const struct GNUNET_PeerIdentity *id,
5659 const struct GNUNET_PeerIdentity *id,
5660 const struct GNUNET_CONFIGURATION_Handle *cfg, 5649 const struct GNUNET_CONFIGURATION_Handle *cfg,
5661 struct GNUNET_TESTING_Daemon *d, const char *emsg) 5650 struct GNUNET_TESTING_Daemon *d, const char *emsg)
5662{ 5651{
@@ -5693,8 +5682,7 @@ schedule_service_start (void *cls,
5693 else 5682 else
5694 { 5683 {
5695 5684
5696 GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, 5685 GNUNET_TESTING_daemon_start_service (peer_ctx->daemon, startup_ctx->service,
5697 startup_ctx->service,
5698 startup_ctx->timeout, 5686 startup_ctx->timeout,
5699 &service_start_callback, startup_ctx); 5687 &service_start_callback, startup_ctx);
5700 GNUNET_free (peer_ctx); 5688 GNUNET_free (peer_ctx);
@@ -5712,29 +5700,29 @@ internal_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5712 return; 5700 return;
5713 } 5701 }
5714 5702
5715 if ((internal_context->peer->pg->starting 5703 if ((internal_context->peer->pg->starting <
5716 < internal_context->peer->pg->max_concurrent_ssh) 5704 internal_context->peer->pg->max_concurrent_ssh) ||
5717 || ((internal_context->hostname != NULL) 5705 ((internal_context->hostname != NULL) &&
5718 && (count_outstanding_at_host (internal_context->hostname, 5706 (count_outstanding_at_host
5719 internal_context->peer->pg) 5707 (internal_context->hostname,
5720 < internal_context->peer->pg->max_concurrent_ssh))) 5708 internal_context->peer->pg) <
5709 internal_context->peer->pg->max_concurrent_ssh)))
5721 { 5710 {
5722 if (internal_context->hostname != NULL) 5711 if (internal_context->hostname != NULL)
5723 increment_outstanding_at_host (internal_context->hostname, 5712 increment_outstanding_at_host (internal_context->hostname,
5724 internal_context->peer->pg); 5713 internal_context->peer->pg);
5725 internal_context->peer->pg->starting++; 5714 internal_context->peer->pg->starting++;
5726 internal_context->peer->daemon 5715 internal_context->peer->daemon =
5727 = GNUNET_TESTING_daemon_start (internal_context->peer->cfg, 5716 GNUNET_TESTING_daemon_start (internal_context->peer->cfg,
5728 internal_context->timeout, 5717 internal_context->timeout, GNUNET_NO,
5729 GNUNET_NO, 5718 internal_context->hostname,
5730 internal_context->hostname, 5719 internal_context->username,
5731 internal_context->username, 5720 internal_context->sshport,
5732 internal_context->sshport, 5721 internal_context->hostkey,
5733 internal_context->hostkey, 5722 &internal_hostkey_callback,
5734 &internal_hostkey_callback, 5723 internal_context,
5735 internal_context, 5724 &internal_startup_callback,
5736 &internal_startup_callback, 5725 internal_context);
5737 internal_context);
5738 } 5726 }
5739 else 5727 else
5740 { 5728 {
@@ -5822,8 +5810,9 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
5822 GNUNET_asprintf (&arg, "%s", helper->host->hostname); 5810 GNUNET_asprintf (&arg, "%s", helper->host->hostname);
5823 5811
5824 /* FIXME: Doesn't support ssh_port option! */ 5812 /* FIXME: Doesn't support ssh_port option! */
5825 helper->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, 5813 helper->proc =
5826 "peerStartHelper.pl", tempdir, NULL); 5814 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
5815 "peerStartHelper.pl", tempdir, NULL);
5827 GNUNET_assert (helper->proc != NULL); 5816 GNUNET_assert (helper->proc != NULL);
5828 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 5817 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5829 "starting peers with cmd ssh %s %s %s\n", arg, 5818 "starting peers with cmd ssh %s %s %s\n", arg,
@@ -5891,9 +5880,9 @@ call_hostkey_callbacks (void *cls,
5891 for (i = 0; i < pg->total; i++) 5880 for (i = 0; i < pg->total; i++)
5892 { 5881 {
5893 if (pg->peers[i].internal_context.hostkey_callback != NULL) 5882 if (pg->peers[i].internal_context.hostkey_callback != NULL)
5894 pg->peers[i].internal_context.hostkey_callback (pg->peers 5883 pg->peers[i].internal_context.hostkey_callback (pg->
5895 [i]. 5884 peers[i].internal_context.
5896 internal_context.hostkey_cls, 5885 hostkey_cls,
5897 &pg->peers[i].daemon->id, 5886 &pg->peers[i].daemon->id,
5898 pg->peers[i].daemon, 5887 pg->peers[i].daemon,
5899 NULL); 5888 NULL);
@@ -6044,16 +6033,17 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6044 if (pg->hosts[i].sshport != 0) 6033 if (pg->hosts[i].sshport != 0)
6045 { 6034 {
6046 GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport); 6035 GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
6047 proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", 6036 proc =
6048 ssh_port_str, 6037 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", ssh_port_str,
6049#if !DEBUG_TESTING 6038#if !DEBUG_TESTING
6050 "-q", 6039 "-q",
6051#endif 6040#endif
6052 arg, "mkdir -p", tmpdir, NULL); 6041 arg, "mkdir -p", tmpdir, NULL);
6053 } 6042 }
6054 else 6043 else
6055 proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, 6044 proc =
6056 "mkdir -p", tmpdir, NULL); 6045 GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
6046 tmpdir, NULL);
6057 GNUNET_assert (proc != NULL); 6047 GNUNET_assert (proc != NULL);
6058 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 6048 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
6059 "Creating remote dir with command ssh %s %s %s\n", arg, 6049 "Creating remote dir with command ssh %s %s %s\n", arg,
@@ -6066,9 +6056,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6066 GNUNET_free (baseservicehome); 6056 GNUNET_free (baseservicehome);
6067 baseservicehome = NULL; 6057 baseservicehome = NULL;
6068 6058
6069 if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", 6059 if (GNUNET_YES ==
6070 "HOSTKEYSFILE", 6060 GNUNET_CONFIGURATION_get_value_string (cfg, "TESTING", "HOSTKEYSFILE",
6071 &hostkeys_file)) 6061 &hostkeys_file))
6072 { 6062 {
6073 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) 6063 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
6074 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 6064 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -6076,12 +6066,12 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6076 else 6066 else
6077 { 6067 {
6078 /* Check hostkey file size, read entire thing into memory */ 6068 /* Check hostkey file size, read entire thing into memory */
6079 fd = GNUNET_DISK_file_open (hostkeys_file, 6069 fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ,
6080 GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE); 6070 GNUNET_DISK_PERM_NONE);
6081 if (NULL == fd) 6071 if (NULL == fd)
6082 { 6072 {
6083 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, 6073 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open",
6084 "open", hostkeys_file); 6074 hostkeys_file);
6085 GNUNET_free (hostkeys_file); 6075 GNUNET_free (hostkeys_file);
6086 for (i = 0; i < pg->num_hosts; i++) 6076 for (i = 0; i < pg->num_hosts; i++)
6087 { 6077 {
@@ -6126,8 +6116,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6126 hostname = pg->hosts[off % hostcnt].hostname; 6116 hostname = pg->hosts[off % hostcnt].hostname;
6127 username = pg->hosts[off % hostcnt].username; 6117 username = pg->hosts[off % hostcnt].username;
6128 sshport = pg->hosts[off % hostcnt].sshport; 6118 sshport = pg->hosts[off % hostcnt].sshport;
6129 pcfg = make_config (cfg, off, &pg->hosts[off % hostcnt].minport, 6119 pcfg =
6130 &upnum, hostname, &fdnum); 6120 make_config (cfg, off, &pg->hosts[off % hostcnt].minport, &upnum,
6121 hostname, &fdnum);
6131 } 6122 }
6132 else 6123 else
6133 { 6124 {
@@ -6146,10 +6137,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6146 continue; 6137 continue;
6147 } 6138 }
6148 6139
6149 if (GNUNET_YES 6140 if (GNUNET_YES ==
6150 == GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", 6141 GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", "SERVICEHOME",
6151 "SERVICEHOME", 6142 &baseservicehome))
6152 &baseservicehome))
6153 { 6143 {
6154 if (hostname != NULL) 6144 if (hostname != NULL)
6155 GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome, 6145 GNUNET_asprintf (&newservicehome, "%s/%s/%d/", baseservicehome,
@@ -6181,9 +6171,8 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6181 pg->peers[off].internal_context.username = username; 6171 pg->peers[off].internal_context.username = username;
6182 pg->peers[off].internal_context.sshport = sshport; 6172 pg->peers[off].internal_context.sshport = sshport;
6183 if (pg->hostkey_data != NULL) 6173 if (pg->hostkey_data != NULL)
6184 pg->peers[off].internal_context.hostkey = &pg->hostkey_data[off 6174 pg->peers[off].internal_context.hostkey =
6185 * 6175 &pg->hostkey_data[off * HOSTKEYFILESIZE];
6186 HOSTKEYFILESIZE];
6187 pg->peers[off].internal_context.hostkey_callback = hostkey_callback; 6176 pg->peers[off].internal_context.hostkey_callback = hostkey_callback;
6188 pg->peers[off].internal_context.hostkey_cls = hostkey_cls; 6177 pg->peers[off].internal_context.hostkey_cls = hostkey_cls;
6189 pg->peers[off].internal_context.start_cb = cb; 6178 pg->peers[off].internal_context.start_cb = cb;
@@ -6194,19 +6183,14 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6194#else 6183#else
6195 if ((pg->hostkey_data != NULL) && (hostcnt > 0)) 6184 if ((pg->hostkey_data != NULL) && (hostcnt > 0))
6196 { 6185 {
6197 pg->peers[off].daemon 6186 pg->peers[off].daemon =
6198 = GNUNET_TESTING_daemon_start (pcfg, 6187 GNUNET_TESTING_daemon_start (pcfg, timeout, GNUNET_YES, hostname,
6199 timeout, 6188 username, sshport,
6200 GNUNET_YES, 6189 pg->peers[off].internal_context.hostkey,
6201 hostname, 6190 &internal_hostkey_callback,
6202 username, 6191 &pg->peers[off].internal_context,
6203 sshport, 6192 &internal_startup_callback,
6204 pg->peers[off]. 6193 &pg->peers[off].internal_context);
6205 internal_context.hostkey,
6206 &internal_hostkey_callback,
6207 &pg->peers[off].internal_context,
6208 &internal_startup_callback,
6209 &pg->peers[off].internal_context);
6210 /** 6194 /**
6211 * At this point, given that we had a hostkeyfile, 6195 * At this point, given that we had a hostkeyfile,
6212 * we can call the hostkey callback! 6196 * we can call the hostkey callback!
@@ -6245,10 +6229,9 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6245 sshport = 0; 6229 sshport = 0;
6246 } 6230 }
6247 6231
6248 if (GNUNET_YES 6232 if (GNUNET_YES ==
6249 == GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", 6233 GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME",
6250 "SERVICEHOME", 6234 &baseservicehome))
6251 &baseservicehome))
6252 { 6235 {
6253 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n", 6236 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "baseservice home is %s\n",
6254 baseservicehome); 6237 baseservicehome);
@@ -6273,17 +6256,16 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
6273 } 6256 }
6274 6257
6275 if (NULL != username) 6258 if (NULL != username)
6276 GNUNET_asprintf (&arg, 6259 GNUNET_asprintf (&arg, "%s@%s:%s", username, pg->hosts[off].hostname,
6277 "%s@%s:%s", 6260 newservicehome);
6278 username, pg->hosts[off].hostname, newservicehome);
6279 else 6261 else
6280 GNUNET_asprintf (&arg, 6262 GNUNET_asprintf (&arg, "%s:%s", pg->hosts[off].hostname,
6281 "%s:%s", pg->hosts[off].hostname, newservicehome); 6263 newservicehome);
6282 6264
6283 /* FIXME: Doesn't support ssh_port option! */ 6265 /* FIXME: Doesn't support ssh_port option! */
6284 proc = GNUNET_OS_start_process (NULL, NULL, 6266 proc =
6285 "rsync", 6267 GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r",
6286 "rsync", "-r", newservicehome, arg, NULL); 6268 newservicehome, arg, NULL);
6287 6269
6288 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 6270 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
6289 "copying directory with command rsync -r %s %s\n", 6271 "copying directory with command rsync -r %s %s\n",
@@ -6338,8 +6320,9 @@ GNUNET_TESTING_daemon_get_by_id (struct GNUNET_TESTING_PeerGroup *pg,
6338 6320
6339 for (i = 0; i < pg->total; i++) 6321 for (i = 0; i < pg->total; i++)
6340 { 6322 {
6341 if (0 == memcmp (&pg->peers[i].daemon->id, peer_id, 6323 if (0 ==
6342 sizeof (struct GNUNET_PeerIdentity))) 6324 memcmp (&pg->peers[i].daemon->id, peer_id,
6325 sizeof (struct GNUNET_PeerIdentity)))
6343 return pg->peers[i].daemon; 6326 return pg->peers[i].daemon;
6344 } 6327 }
6345 return NULL; 6328 return NULL;
@@ -6376,8 +6359,8 @@ restart_callback (void *cls, const struct GNUNET_PeerIdentity *id,
6376 restart_context->callback (restart_context->callback_cls, NULL); 6359 restart_context->callback (restart_context->callback_cls, NULL);
6377 GNUNET_free (restart_context); 6360 GNUNET_free (restart_context);
6378 } 6361 }
6379 else if (restart_context->peers_restart_failed 6362 else if (restart_context->peers_restart_failed +
6380 + restart_context->peers_restarted == 6363 restart_context->peers_restarted ==
6381 restart_context->peer_group->total) 6364 restart_context->peer_group->total)
6382 { 6365 {
6383 restart_context->callback (restart_context->callback_cls, 6366 restart_context->callback (restart_context->callback_cls,
@@ -6417,8 +6400,9 @@ churn_stop_callback (void *cls, const char *emsg)
6417 churn_ctx->num_to_stop--; 6400 churn_ctx->num_to_stop--;
6418 } 6401 }
6419 6402
6420 total_left = (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) 6403 total_left =
6421 + (churn_ctx->num_to_start - churn_ctx->num_failed_start); 6404 (churn_ctx->num_to_stop - churn_ctx->num_failed_stop) +
6405 (churn_ctx->num_to_start - churn_ctx->num_failed_start);
6422 6406
6423 if (total_left == 0) 6407 if (total_left == 0)
6424 { 6408 {
@@ -6523,8 +6507,8 @@ schedule_churn_shutdown_task (void *cls,
6523 */ 6507 */
6524void 6508void
6525GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg, 6509GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6526 char *service, 6510 char *service, unsigned int voff,
6527 unsigned int voff, unsigned int von, 6511 unsigned int von,
6528 struct GNUNET_TIME_Relative timeout, 6512 struct GNUNET_TIME_Relative timeout,
6529 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls) 6513 GNUNET_TESTING_NotifyCompletion cb, void *cb_cls)
6530{ 6514{
@@ -6634,11 +6618,11 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6634 stopped_permute = NULL; 6618 stopped_permute = NULL;
6635 6619
6636 if (running > 0) 6620 if (running > 0)
6637 running_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 6621 running_permute =
6638 running); 6622 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, running);
6639 if (stopped > 0) 6623 if (stopped > 0)
6640 stopped_permute = GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, 6624 stopped_permute =
6641 stopped); 6625 GNUNET_CRYPTO_random_permute (GNUNET_CRYPTO_QUALITY_WEAK, stopped);
6642 6626
6643 total_running = running; 6627 total_running = running;
6644 total_stopped = stopped; 6628 total_stopped = stopped;
@@ -6707,8 +6691,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6707#endif 6691#endif
6708 GNUNET_assert (running_arr != NULL); 6692 GNUNET_assert (running_arr != NULL);
6709 peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext)); 6693 peer_shutdown_ctx = GNUNET_malloc (sizeof (struct PeerShutdownContext));
6710 peer_shutdown_ctx->daemon 6694 peer_shutdown_ctx->daemon =
6711 = pg->peers[running_arr[running_permute[i]]].daemon; 6695 pg->peers[running_arr[running_permute[i]]].daemon;
6712 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx; 6696 peer_shutdown_ctx->shutdown_ctx = shutdown_ctx;
6713 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx); 6697 GNUNET_SCHEDULER_add_now (&schedule_churn_shutdown_task, peer_shutdown_ctx);
6714 } 6698 }
@@ -6730,8 +6714,8 @@ GNUNET_TESTING_daemons_churn (struct GNUNET_TESTING_PeerGroup *pg,
6730 GNUNET_assert (stopped_arr != NULL); 6714 GNUNET_assert (stopped_arr != NULL);
6731 peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext)); 6715 peer_restart_ctx = GNUNET_malloc (sizeof (struct PeerRestartContext));
6732 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx; 6716 peer_restart_ctx->churn_restart_ctx = churn_startup_ctx;
6733 peer_restart_ctx->daemon 6717 peer_restart_ctx->daemon =
6734 = pg->peers[stopped_arr[stopped_permute[i]]].daemon; 6718 pg->peers[stopped_arr[stopped_permute[i]]].daemon;
6735 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx); 6719 GNUNET_SCHEDULER_add_now (&schedule_churn_restart, peer_restart_ctx);
6736 } 6720 }
6737 6721
@@ -6812,8 +6796,8 @@ GNUNET_TESTING_daemons_restart (struct GNUNET_TESTING_PeerGroup *pg,
6812 6796
6813 for (off = 0; off < pg->total; off++) 6797 for (off = 0; off < pg->total; off++)
6814 { 6798 {
6815 GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, 6799 GNUNET_TESTING_daemon_restart (pg->peers[off].daemon, &restart_callback,
6816 &restart_callback, restart_context); 6800 restart_context);
6817 } 6801 }
6818 } 6802 }
6819} 6803}
@@ -6851,8 +6835,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
6851 churn_ctx->cb_cls = cb_cls; 6835 churn_ctx->cb_cls = cb_cls;
6852 shutdown_ctx->cb_cls = churn_ctx; 6836 shutdown_ctx->cb_cls = churn_ctx;
6853 GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout, 6837 GNUNET_TESTING_daemon_stop (pg->peers[offset].daemon, timeout,
6854 &churn_stop_callback, shutdown_ctx, 6838 &churn_stop_callback, shutdown_ctx, GNUNET_NO,
6855 GNUNET_NO, GNUNET_YES); 6839 GNUNET_YES);
6856 } 6840 }
6857 } 6841 }
6858 else if (GNUNET_YES == desired_status) 6842 else if (GNUNET_YES == desired_status)
@@ -6866,9 +6850,8 @@ GNUNET_TESTING_daemons_vary (struct GNUNET_TESTING_PeerGroup *pg,
6866 churn_ctx->cb = cb; 6850 churn_ctx->cb = cb;
6867 churn_ctx->cb_cls = cb_cls; 6851 churn_ctx->cb_cls = cb_cls;
6868 startup_ctx->churn_ctx = churn_ctx; 6852 startup_ctx->churn_ctx = churn_ctx;
6869 GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, 6853 GNUNET_TESTING_daemon_start_stopped (pg->peers[offset].daemon, timeout,
6870 timeout, &churn_start_callback, 6854 &churn_start_callback, startup_ctx);
6871 startup_ctx);
6872 } 6855 }
6873 } 6856 }
6874 else 6857 else
@@ -6908,9 +6891,9 @@ internal_shutdown_callback (void *cls, const char *emsg)
6908 shutdown_ctx->peers_failed++; 6891 shutdown_ctx->peers_failed++;
6909 } 6892 }
6910 6893
6911 if ((shutdown_ctx->cb != NULL) && (shutdown_ctx->peers_down 6894 if ((shutdown_ctx->cb != NULL) &&
6912 + shutdown_ctx->peers_failed == 6895 (shutdown_ctx->peers_down + shutdown_ctx->peers_failed ==
6913 shutdown_ctx->total_peers)) 6896 shutdown_ctx->total_peers))
6914 { 6897 {
6915 if (shutdown_ctx->peers_failed > 0) 6898 if (shutdown_ctx->peers_failed > 0)
6916 shutdown_ctx->cb (shutdown_ctx->cb_cls, 6899 shutdown_ctx->cb (shutdown_ctx->cb_cls,
@@ -6957,11 +6940,11 @@ schedule_shutdown_task (void *cls,
6957 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx; 6940 shutdown_ctx = peer_shutdown_ctx->shutdown_ctx;
6958 GNUNET_assert (shutdown_ctx != NULL); 6941 GNUNET_assert (shutdown_ctx != NULL);
6959 6942
6960 if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) 6943 if ((shutdown_ctx->outstanding < shutdown_ctx->pg->max_concurrent_ssh) ||
6961 || ((peer_shutdown_ctx->daemon->hostname != NULL) 6944 ((peer_shutdown_ctx->daemon->hostname != NULL) &&
6962 && (count_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, 6945 (count_outstanding_at_host
6963 shutdown_ctx->pg) 6946 (peer_shutdown_ctx->daemon->hostname,
6964 < shutdown_ctx->pg->max_concurrent_ssh))) 6947 shutdown_ctx->pg) < shutdown_ctx->pg->max_concurrent_ssh)))
6965 { 6948 {
6966 if (peer_shutdown_ctx->daemon->hostname != NULL) 6949 if (peer_shutdown_ctx->daemon->hostname != NULL)
6967 increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname, 6950 increment_outstanding_at_host (peer_shutdown_ctx->daemon->hostname,
@@ -7001,9 +6984,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7001 int ret; 6984 int ret;
7002 6985
7003 /* Check for a hostfile containing user@host:port triples */ 6986 /* Check for a hostfile containing user@host:port triples */
7004 if (GNUNET_OK 6987 if (GNUNET_OK !=
7005 != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", 6988 GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile",
7006 &hostfile)) 6989 &hostfile))
7007 return NULL; 6990 return NULL;
7008 6991
7009 hosts = NULL; 6992 hosts = NULL;
@@ -7012,8 +6995,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7012 if (hostfile != NULL) 6995 if (hostfile != NULL)
7013 { 6996 {
7014 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) 6997 if (GNUNET_OK != GNUNET_DISK_file_test (hostfile))
7015 GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ 6998 GNUNET_DISK_fn_write (hostfile, NULL, 0,
7016 | GNUNET_DISK_PERM_USER_WRITE); 6999 GNUNET_DISK_PERM_USER_READ |
7000 GNUNET_DISK_PERM_USER_WRITE);
7017 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) 7001 if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0))
7018 { 7002 {
7019 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 7003 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -7045,9 +7029,9 @@ GNUNET_TESTING_hosts_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
7045 { 7029 {
7046 data[count] = '\0'; 7030 data[count] = '\0';
7047 temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); 7031 temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host));
7048 ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", 7032 ret =
7049 &temphost->username, &temphost->hostname, 7033 sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd",
7050 &temphost->port); 7034 &temphost->username, &temphost->hostname, &temphost->port);
7051 if (3 == ret) 7035 if (3 == ret)
7052 { 7036 {
7053 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 7037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -7100,9 +7084,8 @@ GNUNET_TESTING_daemons_stop (struct GNUNET_TESTING_PeerGroup *pg,
7100 GNUNET_assert (pg->total > 0); 7084 GNUNET_assert (pg->total > 0);
7101 7085
7102 shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext)); 7086 shutdown_ctx = GNUNET_malloc (sizeof (struct ShutdownContext));
7103 shutdown_ctx->delete_files = GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, 7087 shutdown_ctx->delete_files =
7104 "TESTING", 7088 GNUNET_CONFIGURATION_get_value_yesno (pg->cfg, "TESTING", "DELETE_FILES");
7105 "DELETE_FILES");
7106 shutdown_ctx->cb = cb; 7089 shutdown_ctx->cb = cb;
7107 shutdown_ctx->cb_cls = cb_cls; 7090 shutdown_ctx->cb_cls = cb_cls;
7108 shutdown_ctx->total_peers = pg->total; 7091 shutdown_ctx->total_peers = pg->total;