aboutsummaryrefslogtreecommitdiff
path: root/src/testing/testing_group.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-07-15 11:21:14 +0000
committerChristian Grothoff <christian@grothoff.org>2011-07-15 11:21:14 +0000
commitf0b1d3ed8c95c68d6c9353774c93c28e0c0605b8 (patch)
tree219cc13c7b53003db30f62ef9b8e53cf9d122d82 /src/testing/testing_group.c
parentc6becd402caf853f1cebe637bfb4664be4cba9bd (diff)
downloadgnunet-f0b1d3ed8c95c68d6c9353774c93c28e0c0605b8.tar.gz
gnunet-f0b1d3ed8c95c68d6c9353774c93c28e0c0605b8.zip
leaks
Diffstat (limited to 'src/testing/testing_group.c')
-rw-r--r--src/testing/testing_group.c49
1 files changed, 33 insertions, 16 deletions
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 76815d76a..ccc5e79f1 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -5913,15 +5913,28 @@ GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg,
5913 &hostkeys_file)) 5913 &hostkeys_file))
5914 { 5914 {
5915 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file)) 5915 if (GNUNET_YES != GNUNET_DISK_file_test (hostkeys_file))
5916 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Couldn't read hostkeys file!\n"); 5916 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
5917 _("Could not read hostkeys file!\n"));
5917 else 5918 else
5918 { 5919 {
5919 /* Check hostkey file size, read entire thing into memory */ 5920 /* Check hostkey file size, read entire thing into memory */
5920 fd = GNUNET_DISK_file_open (hostkeys_file, GNUNET_DISK_OPEN_READ, 5921 fd = GNUNET_DISK_file_open (hostkeys_file,
5922 GNUNET_DISK_OPEN_READ,
5921 GNUNET_DISK_PERM_NONE); 5923 GNUNET_DISK_PERM_NONE);
5922 if (NULL == fd) 5924 if (NULL == fd)
5923 { 5925 {
5924 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", hostkeys_file); 5926 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
5927 "open",
5928 hostkeys_file);
5929 GNUNET_free (hostkeys_file);
5930 for (i=0;i<pg->num_hosts;i++)
5931 {
5932 GNUNET_free (pg->hosts[i].hostname);
5933 GNUNET_free_non_null (pg->hosts[i].username);
5934 }
5935 GNUNET_free (pg->peers);
5936 GNUNET_free (pg->hosts);
5937 GNUNET_free (pg);
5925 return NULL; 5938 return NULL;
5926 } 5939 }
5927 5940
@@ -5929,8 +5942,7 @@ GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg,
5929 GNUNET_YES)) 5942 GNUNET_YES))
5930 fs = 0; 5943 fs = 0;
5931 5944
5932 GNUNET_log ( 5945 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5933 GNUNET_ERROR_TYPE_DEBUG,
5934 "Found file size %llu for hostkeys, expect hostkeys to be size %d\n", 5946 "Found file size %llu for hostkeys, expect hostkeys to be size %d\n",
5935 fs, HOSTKEYFILESIZE); 5947 fs, HOSTKEYFILESIZE);
5936 5948
@@ -5944,7 +5956,8 @@ GNUNET_TESTING_daemons_start(const struct GNUNET_CONFIGURATION_Handle *cfg,
5944 { 5956 {
5945 total_hostkeys = fs / HOSTKEYFILESIZE; 5957 total_hostkeys = fs / HOSTKEYFILESIZE;
5946 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5958 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5947 "Will read %llu hostkeys from file\n", total_hostkeys); 5959 "Will read %llu hostkeys from file\n",
5960 total_hostkeys);
5948 pg->hostkey_data = GNUNET_malloc_large (fs); 5961 pg->hostkey_data = GNUNET_malloc_large (fs);
5949 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, pg->hostkey_data, fs)); 5962 GNUNET_assert (fs == GNUNET_DISK_file_read (fd, pg->hostkey_data, fs));
5950 GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fd)); 5963 GNUNET_assert(GNUNET_OK == GNUNET_DISK_file_close(fd));
@@ -6104,8 +6117,7 @@ GNUNET_TESTING_daemon_get(struct GNUNET_TESTING_PeerGroup *pg,
6104{ 6117{
6105 if (position < pg->total) 6118 if (position < pg->total)
6106 return pg->peers[position].daemon; 6119 return pg->peers[position].daemon;
6107 else 6120 return NULL;
6108 return NULL;
6109} 6121}
6110 6122
6111/* 6123/*
@@ -6129,7 +6141,6 @@ GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg,
6129 sizeof(struct GNUNET_PeerIdentity))) 6141 sizeof(struct GNUNET_PeerIdentity)))
6130 return pg->peers[i].daemon; 6142 return pg->peers[i].daemon;
6131 } 6143 }
6132
6133 return NULL; 6144 return NULL;
6134} 6145}
6135 6146
@@ -6143,7 +6154,7 @@ GNUNET_TESTING_daemon_get_by_id(struct GNUNET_TESTING_PeerGroup *pg,
6143 * @param d handle to the daemon that was restarted 6154 * @param d handle to the daemon that was restarted
6144 * @param emsg NULL on success 6155 * @param emsg NULL on success
6145 */ 6156 */
6146void 6157static void
6147restart_callback(void *cls, const struct GNUNET_PeerIdentity *id, 6158restart_callback(void *cls, const struct GNUNET_PeerIdentity *id,
6148 const struct GNUNET_CONFIGURATION_Handle *cfg, 6159 const struct GNUNET_CONFIGURATION_Handle *cfg,
6149 struct GNUNET_TESTING_Daemon *d, const char *emsg) 6160 struct GNUNET_TESTING_Daemon *d, const char *emsg)
@@ -6182,7 +6193,7 @@ restart_callback(void *cls, const struct GNUNET_PeerIdentity *id,
6182 * @param emsg NULL on success, non-NULL on failure 6193 * @param emsg NULL on success, non-NULL on failure
6183 * 6194 *
6184 */ 6195 */
6185void 6196static void
6186churn_stop_callback(void *cls, const char *emsg) 6197churn_stop_callback(void *cls, const char *emsg)
6187{ 6198{
6188 struct ShutdownContext *shutdown_ctx = cls; 6199 struct ShutdownContext *shutdown_ctx = cls;
@@ -6286,6 +6297,7 @@ schedule_churn_shutdown_task(void *cls,
6286 } 6297 }
6287} 6298}
6288 6299
6300
6289/** 6301/**
6290 * Simulate churn by stopping some peers (and possibly 6302 * Simulate churn by stopping some peers (and possibly
6291 * re-starting others if churn is called multiple times). This 6303 * re-starting others if churn is called multiple times). This
@@ -6481,6 +6493,7 @@ GNUNET_TESTING_daemons_churn(struct GNUNET_TESTING_PeerGroup *pg,
6481 GNUNET_free_non_null (stopped_permute); 6493 GNUNET_free_non_null (stopped_permute);
6482} 6494}
6483 6495
6496
6484/** 6497/**
6485 * Restart all peers in the given group. 6498 * Restart all peers in the given group.
6486 * 6499 *
@@ -6512,6 +6525,7 @@ GNUNET_TESTING_daemons_restart(struct GNUNET_TESTING_PeerGroup *pg,
6512 } 6525 }
6513} 6526}
6514 6527
6528
6515/** 6529/**
6516 * Start or stop an individual peer from the given group. 6530 * Start or stop an individual peer from the given group.
6517 * 6531 *
@@ -6568,13 +6582,14 @@ GNUNET_TESTING_daemons_vary(struct GNUNET_TESTING_PeerGroup *pg,
6568 GNUNET_break (0); 6582 GNUNET_break (0);
6569} 6583}
6570 6584
6585
6571/** 6586/**
6572 * Callback for shutting down peers in a peer group. 6587 * Callback for shutting down peers in a peer group.
6573 * 6588 *
6574 * @param cls closure (struct ShutdownContext) 6589 * @param cls closure (struct ShutdownContext)
6575 * @param emsg NULL on success 6590 * @param emsg NULL on success
6576 */ 6591 */
6577void 6592static void
6578internal_shutdown_callback(void *cls, const char *emsg) 6593internal_shutdown_callback(void *cls, const char *emsg)
6579{ 6594{
6580 struct PeerShutdownContext *peer_shutdown_ctx = cls; 6595 struct PeerShutdownContext *peer_shutdown_ctx = cls;
@@ -6624,6 +6639,7 @@ internal_shutdown_callback(void *cls, const char *emsg)
6624 GNUNET_free(peer_shutdown_ctx); 6639 GNUNET_free(peer_shutdown_ctx);
6625} 6640}
6626 6641
6642
6627/** 6643/**
6628 * Task to rate limit the number of outstanding peer shutdown 6644 * Task to rate limit the number of outstanding peer shutdown
6629 * requests. This is necessary for making sure we don't do 6645 * requests. This is necessary for making sure we don't do
@@ -6663,6 +6679,7 @@ schedule_shutdown_task(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
6663 6679
6664} 6680}
6665 6681
6682
6666/** 6683/**
6667 * Shutdown all peers started in the given group. 6684 * Shutdown all peers started in the given group.
6668 * 6685 *
@@ -6741,12 +6758,12 @@ GNUNET_TESTING_daemons_stop(struct GNUNET_TESTING_PeerGroup *pg,
6741 } 6758 }
6742#else 6759#else
6743 if (pg->peers[off].allowed_peers != NULL) 6760 if (pg->peers[off].allowed_peers != NULL)
6744 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[off].allowed_peers); 6761 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[off].allowed_peers);
6745 if (pg->peers[off].connect_peers != NULL) 6762 if (pg->peers[off].connect_peers != NULL)
6746 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[off].connect_peers); 6763 GNUNET_CONTAINER_multihashmap_destroy (pg->peers[off].connect_peers);
6747 if (pg->peers[off].blacklisted_peers != NULL) 6764 if (pg->peers[off].blacklisted_peers != NULL)
6748 GNUNET_CONTAINER_multihashmap_destroy (pg-> 6765 GNUNET_CONTAINER_multihashmap_destroy (pg->
6749 peers[off].blacklisted_peers); 6766 peers[off].blacklisted_peers);
6750#endif 6767#endif
6751 } 6768 }
6752} 6769}