diff options
author | Florian Dold <florian.dold@gmail.com> | 2013-07-10 01:31:13 +0000 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2013-07-10 01:31:13 +0000 |
commit | 6b8400966a5e6c2194785b3a33f91b748cfa7b7b (patch) | |
tree | 0dafa7ba24c7a6dbb852fdedfd1822cd1e4835c0 /src/consensus | |
parent | 084cb3e09007ef50a3d9bd29514c8ec455249633 (diff) | |
download | gnunet-6b8400966a5e6c2194785b3a33f91b748cfa7b7b.tar.gz gnunet-6b8400966a5e6c2194785b3a33f91b748cfa7b7b.zip |
- set service working
- set profiler
Diffstat (limited to 'src/consensus')
-rw-r--r-- | src/consensus/Makefile.am | 14 | ||||
-rw-r--r-- | src/consensus/consensus_api.c | 2 | ||||
-rw-r--r-- | src/consensus/gnunet-consensus-start-peers.c | 186 | ||||
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 2 |
4 files changed, 2 insertions, 202 deletions
diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am index 914fbdef8..4b81baa59 100644 --- a/src/consensus/Makefile.am +++ b/src/consensus/Makefile.am | |||
@@ -16,8 +16,7 @@ if USE_COVERAGE | |||
16 | endif | 16 | endif |
17 | 17 | ||
18 | bin_PROGRAMS = \ | 18 | bin_PROGRAMS = \ |
19 | gnunet-consensus \ | 19 | gnunet-consensus |
20 | gnunet-consensus-start-peers | ||
21 | 20 | ||
22 | libexec_PROGRAMS = \ | 21 | libexec_PROGRAMS = \ |
23 | gnunet-service-consensus | 22 | gnunet-service-consensus |
@@ -41,17 +40,6 @@ gnunet_consensus_LDADD = \ | |||
41 | gnunet_consensus_DEPENDENCIES = \ | 40 | gnunet_consensus_DEPENDENCIES = \ |
42 | libgnunetconsensus.la | 41 | libgnunetconsensus.la |
43 | 42 | ||
44 | gnunet_consensus_start_peers_SOURCES = \ | ||
45 | gnunet-consensus-start-peers.c | ||
46 | gnunet_consensus_start_peers_LDADD = \ | ||
47 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
48 | $(top_builddir)/src/testbed/libgnunettestbed.la \ | ||
49 | $(top_builddir)/src/consensus/libgnunetconsensus.la \ | ||
50 | $(GN_LIBINTL) | ||
51 | gnunet_consensus_start_peers_DEPENDENCIES = \ | ||
52 | libgnunetconsensus.la | ||
53 | |||
54 | |||
55 | gnunet_service_consensus_SOURCES = \ | 43 | gnunet_service_consensus_SOURCES = \ |
56 | gnunet-service-consensus.c | 44 | gnunet-service-consensus.c |
57 | gnunet_service_consensus_LDADD = \ | 45 | gnunet_service_consensus_LDADD = \ |
diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c index a1dc40826..7690dc059 100644 --- a/src/consensus/consensus_api.c +++ b/src/consensus/consensus_api.c | |||
@@ -205,7 +205,7 @@ GNUNET_CONSENSUS_create (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
205 | 205 | ||
206 | consensus->client = GNUNET_CLIENT_connect ("consensus", cfg); | 206 | consensus->client = GNUNET_CLIENT_connect ("consensus", cfg); |
207 | consensus->mq = GNUNET_MQ_queue_for_connection_client (consensus->client, | 207 | consensus->mq = GNUNET_MQ_queue_for_connection_client (consensus->client, |
208 | mq_handlers, consensus); | 208 | mq_handlers, NULL, consensus); |
209 | 209 | ||
210 | GNUNET_assert (consensus->client != NULL); | 210 | GNUNET_assert (consensus->client != NULL); |
211 | 211 | ||
diff --git a/src/consensus/gnunet-consensus-start-peers.c b/src/consensus/gnunet-consensus-start-peers.c deleted file mode 100644 index 05ba05691..000000000 --- a/src/consensus/gnunet-consensus-start-peers.c +++ /dev/null | |||
@@ -1,186 +0,0 @@ | |||
1 | |||
2 | /* | ||
3 | This file is part of GNUnet | ||
4 | (C) 2012 Christian Grothoff (and other contributing authors) | ||
5 | |||
6 | GNUnet is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published | ||
8 | by the Free Software Foundation; either version 2, or (at your | ||
9 | option) any later version. | ||
10 | |||
11 | GNUnet is distributed in the hope that it will be useful, but | ||
12 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
14 | General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNUnet; see the file COPYING. If not, write to the | ||
18 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. | ||
20 | */ | ||
21 | |||
22 | /** | ||
23 | * @file consensus/gnunet-consensus-start-peers.c | ||
24 | * @brief Starts peers with testebed on localhost, | ||
25 | * prints their configuration files and waits for ^C. | ||
26 | * @author Florian Dold | ||
27 | */ | ||
28 | #include "platform.h" | ||
29 | #include "gnunet_util_lib.h" | ||
30 | #include "gnunet_testbed_service.h" | ||
31 | |||
32 | |||
33 | static char *config_template_file; | ||
34 | static unsigned int num_peers_requested = 2; | ||
35 | static struct GNUNET_TESTBED_Peer **peers; | ||
36 | |||
37 | |||
38 | /** | ||
39 | * Callback to be called when the requested peer information is available | ||
40 | * | ||
41 | * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information() | ||
42 | * @param op the operation this callback corresponds to | ||
43 | * @param pinfo the result; will be NULL if the operation has failed | ||
44 | * @param emsg error message if the operation has failed; will be NULL if the | ||
45 | * operation is successfull | ||
46 | */ | ||
47 | static void | ||
48 | peer_info_cb (void *cb_cls, | ||
49 | struct GNUNET_TESTBED_Operation | ||
50 | *op, | ||
51 | const struct | ||
52 | GNUNET_TESTBED_PeerInformation | ||
53 | *pinfo, | ||
54 | const char *emsg) | ||
55 | { | ||
56 | GNUNET_assert (NULL == emsg); | ||
57 | if (pinfo->pit == GNUNET_TESTBED_PIT_IDENTITY) | ||
58 | { | ||
59 | struct GNUNET_CRYPTO_HashAsciiEncoded enc; | ||
60 | GNUNET_CRYPTO_hash_to_enc (&pinfo->result.id->hashPubKey, &enc); | ||
61 | printf("peer %td identity:\n", ((struct GNUNET_TESTBED_Peer **) cb_cls) - &peers[0]); | ||
62 | printf("%s\n", (char *)&enc); | ||
63 | } | ||
64 | else if (pinfo->pit == GNUNET_TESTBED_PIT_CONFIGURATION) | ||
65 | { | ||
66 | char *tmpfilename; | ||
67 | if (NULL == (tmpfilename = GNUNET_DISK_mktemp ("gnunet-consensus"))) | ||
68 | { | ||
69 | GNUNET_break (0); | ||
70 | GNUNET_SCHEDULER_shutdown (); | ||
71 | return; | ||
72 | } | ||
73 | if (GNUNET_SYSERR == | ||
74 | GNUNET_CONFIGURATION_write (pinfo->result.cfg, | ||
75 | tmpfilename)) | ||
76 | { | ||
77 | GNUNET_break (0); | ||
78 | return; | ||
79 | } | ||
80 | printf("peer %td config file:\n", ((struct GNUNET_TESTBED_Peer **) cb_cls) - &peers[0]); | ||
81 | printf("%s\n", tmpfilename); | ||
82 | } | ||
83 | else | ||
84 | { | ||
85 | GNUNET_assert (0); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | |||
90 | |||
91 | /** | ||
92 | * Signature of the event handler function called by the | ||
93 | * respective event controller. | ||
94 | * | ||
95 | * @param cls closure | ||
96 | * @param event information about the event | ||
97 | */ | ||
98 | static void | ||
99 | controller_cb(void *cls, | ||
100 | const struct GNUNET_TESTBED_EventInformation *event) | ||
101 | { | ||
102 | GNUNET_assert (0); | ||
103 | } | ||
104 | |||
105 | |||
106 | |||
107 | |||
108 | /** | ||
109 | * Signature of a main function for a testcase. | ||
110 | * | ||
111 | * @param cls closure | ||
112 | * @param num_peers number of peers in 'peers' | ||
113 | * @param started_peers handle to peers being run in the testbed. NULL upon | ||
114 | * timeout (see GNUNET_TESTBED_test_run()). | ||
115 | * @param links_succeeded the number of overlay link connection attempts that | ||
116 | * succeeded | ||
117 | * @param links_failed the number of overlay link connection attempts that | ||
118 | * failed | ||
119 | */ | ||
120 | static void | ||
121 | test_master (void *cls, | ||
122 | unsigned int num_peers, | ||
123 | struct GNUNET_TESTBED_Peer **started_peers, | ||
124 | unsigned int links_succeeded, | ||
125 | unsigned int links_failed) | ||
126 | { | ||
127 | int i; | ||
128 | |||
129 | printf("started %d peers\n", num_peers); | ||
130 | peers = started_peers; | ||
131 | |||
132 | for (i = 0; i < num_peers; i++) | ||
133 | { | ||
134 | GNUNET_TESTBED_peer_get_information (peers[i], | ||
135 | GNUNET_TESTBED_PIT_IDENTITY, | ||
136 | peer_info_cb, | ||
137 | &peers[i]); | ||
138 | GNUNET_TESTBED_peer_get_information (peers[i], | ||
139 | GNUNET_TESTBED_PIT_CONFIGURATION, | ||
140 | peer_info_cb, | ||
141 | &peers[i]); | ||
142 | } | ||
143 | } | ||
144 | |||
145 | |||
146 | static void | ||
147 | run (void *cls, char *const *args, const char *cfgfile, | ||
148 | const struct GNUNET_CONFIGURATION_Handle *config) | ||
149 | { | ||
150 | if (NULL == config_template_file) | ||
151 | { | ||
152 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "no template file specified\n"); | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | (void) GNUNET_TESTBED_test_run ("gnunet-consensus-start-peers", | ||
157 | config_template_file, | ||
158 | num_peers_requested, | ||
159 | 0, | ||
160 | controller_cb, | ||
161 | NULL, | ||
162 | test_master, | ||
163 | NULL); | ||
164 | } | ||
165 | |||
166 | |||
167 | int | ||
168 | main (int argc, char **argv) | ||
169 | { | ||
170 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
171 | { 't', "config-template", "TEMPLATE", | ||
172 | gettext_noop ("start peers with the given template configuration"), | ||
173 | GNUNET_YES, &GNUNET_GETOPT_set_string, &config_template_file }, | ||
174 | { 'n', "num-peers", "NUM", | ||
175 | gettext_noop ("number of peers to start"), | ||
176 | GNUNET_YES, &GNUNET_GETOPT_set_uint, &num_peers_requested }, | ||
177 | GNUNET_GETOPT_OPTION_END | ||
178 | }; | ||
179 | |||
180 | /* run without scheduler, as test_run already does this */ | ||
181 | GNUNET_PROGRAM_run2 (argc, argv, "gnunet-consensus-start-peers", | ||
182 | "help", | ||
183 | options, &run, NULL, GNUNET_YES); | ||
184 | return 0; | ||
185 | } | ||
186 | |||
diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 9cde0e46b..1245dcca4 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c | |||
@@ -266,8 +266,6 @@ have_exp_subround_finished (const struct ConsensusSession *session) | |||
266 | } | 266 | } |
267 | 267 | ||
268 | 268 | ||
269 | |||
270 | |||
271 | /** | 269 | /** |
272 | * Destroy a session, free all resources associated with it. | 270 | * Destroy a session, free all resources associated with it. |
273 | * | 271 | * |