diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-15 21:39:13 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-15 21:39:13 +0000 |
commit | e3a7cd0f53f7a91b27b95e9b7fc0786f52c9e9ac (patch) | |
tree | 0d1e773b42ac89f1058ea466975d8940852ded36 | |
parent | 0e255e78a2f74e70f749431d1ab97198c572e257 (diff) | |
download | gnunet-e3a7cd0f53f7a91b27b95e9b7fc0786f52c9e9ac.tar.gz gnunet-e3a7cd0f53f7a91b27b95e9b7fc0786f52c9e9ac.zip |
work on migration
-rw-r--r-- | TODO | 13 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/fs/fs.h | 7 | ||||
-rw-r--r-- | src/fs/gnunet-service-fs.c | 40 | ||||
-rw-r--r-- | src/migration/Makefile.am | 34 | ||||
-rw-r--r-- | src/migration/gnunet-daemon-migration.c | 378 | ||||
-rw-r--r-- | src/migration/test_gnunet_daemon_migration.c | 184 | ||||
-rw-r--r-- | src/migration/test_gnunet_daemon_migration_data.conf | 37 | ||||
-rw-r--r-- | src/util/scheduler.c | 3 |
10 files changed, 48 insertions, 653 deletions
@@ -1,25 +1,12 @@ | |||
1 | 0.9.0pre1: | 1 | 0.9.0pre1: |
2 | * FS-LIB: | ||
3 | - _start functions should return void | ||
4 | * MIGRATION [CG] | 2 | * MIGRATION [CG] |
5 | - on-demand encoding => move logic to block-library!? | 3 | - on-demand encoding => move logic to block-library!? |
6 | - peer selection => how to consider latency/bw/etc? | 4 | - peer selection => how to consider latency/bw/etc? |
7 | - content transmission => how often the same block? | 5 | - content transmission => how often the same block? |
8 | - how to select delay before next migration? | 6 | - how to select delay before next migration? |
9 | - migration to us | ||
10 | - testing | 7 | - testing |
11 | - integrate with FS or not? (peer list, index/on-demand encoding, block code, | ||
12 | inbound priority assignment; all would be easier with tight integration!) | ||
13 | * FS: [CG] | 8 | * FS: [CG] |
14 | - gnunet-service-fs (hot-path routing, load-based routing, nitpicks) | 9 | - gnunet-service-fs (hot-path routing, load-based routing, nitpicks) |
15 | - [gnunet-service-fs.c:208]: member 'LocalGetContext::results_bf_size' is never used | ||
16 | - [gnunet-service-fs.c:501]: member 'PendingRequest::used_pids_size' is never used | ||
17 | - [gnunet-service-fs.c:654]: member 'ConnectedPeer::last_client_replies' is never used | ||
18 | - [gnunet-service-fs.c:669]: member 'ConnectedPeer::avg_delay' is never used | ||
19 | - [gnunet-service-fs.c:675]: member 'ConnectedPeer::avg_priority' is never used | ||
20 | - [gnunet-service-fs.c:688]: member 'ConnectedPeer::pending_requests' is never used | ||
21 | - [gnunet-service-fs.c:694]: member 'ConnectedPeer::last_p2p_replies_woff' is never used | ||
22 | - [gnunet-service-fs.c:700]: member 'ConnectedPeer::last_client_replies_woff' is never used | ||
23 | - GAP improvements: | 10 | - GAP improvements: |
24 | + active reply route caching design & implementation of service; gap extension! | 11 | + active reply route caching design & implementation of service; gap extension! |
25 | * TBENCH: [MW] | 12 | * TBENCH: [MW] |
diff --git a/configure.ac b/configure.ac index 0fd4d43a1..f3e2135bd 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -663,7 +663,6 @@ src/hello/Makefile | |||
663 | src/include/Makefile | 663 | src/include/Makefile |
664 | src/include/gnunet_directories.h | 664 | src/include/gnunet_directories.h |
665 | src/hostlist/Makefile | 665 | src/hostlist/Makefile |
666 | src/migration/Makefile | ||
667 | src/nat/Makefile | 666 | src/nat/Makefile |
668 | src/nat/libnatpmp/Makefile | 667 | src/nat/libnatpmp/Makefile |
669 | src/nat/miniupnp/Makefile | 668 | src/nat/miniupnp/Makefile |
diff --git a/src/Makefile.am b/src/Makefile.am index 9381020f4..9bd75d892 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -23,5 +23,5 @@ SUBDIRS = \ | |||
23 | testing \ | 23 | testing \ |
24 | hostlist \ | 24 | hostlist \ |
25 | topology \ | 25 | topology \ |
26 | $(NAT_DIR) | 26 | $(NAT_DIR) \ |
27 | 27 | fs | |
diff --git a/src/fs/fs.h b/src/fs/fs.h index 3277ea340..aff90d4fe 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h | |||
@@ -42,6 +42,13 @@ | |||
42 | #define MAX_MIGRATION_QUEUE 32 | 42 | #define MAX_MIGRATION_QUEUE 32 |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Ratio for moving average delay calculation. The previous | ||
46 | * average goes in with a factor of (n-1) into the calculation. | ||
47 | * Must be > 0. | ||
48 | */ | ||
49 | #define RUNAVG_DELAY_N 16 | ||
50 | |||
51 | /** | ||
45 | * Size of the individual blocks used for file-sharing. | 52 | * Size of the individual blocks used for file-sharing. |
46 | */ | 53 | */ |
47 | #define DBLOCK_SIZE (32*1024) | 54 | #define DBLOCK_SIZE (32*1024) |
diff --git a/src/fs/gnunet-service-fs.c b/src/fs/gnunet-service-fs.c index a08a041da..418ed459a 100644 --- a/src/fs/gnunet-service-fs.c +++ b/src/fs/gnunet-service-fs.c | |||
@@ -27,10 +27,9 @@ | |||
27 | * - TTL/priority calculations are absent! | 27 | * - TTL/priority calculations are absent! |
28 | * TODO: | 28 | * TODO: |
29 | * - have non-zero preference / priority for requests we initiate! | 29 | * - have non-zero preference / priority for requests we initiate! |
30 | * - track stats for hot-path routing | ||
31 | * - implement hot-path routing decision procedure | 30 | * - implement hot-path routing decision procedure |
32 | * - implement: bound_priority, test_load_too_high, validate_nblock | 31 | * - implement: bound_priority, test_load_too_high, validate_nblock |
33 | * - add content migration support (store locally) [or create new service] | 32 | * - add content migration support (forward from migration list) |
34 | * - statistics | 33 | * - statistics |
35 | */ | 34 | */ |
36 | #include "platform.h" | 35 | #include "platform.h" |
@@ -482,6 +481,7 @@ struct PendingRequest | |||
482 | struct GNUNET_DATASTORE_QueueEntry *qe; | 481 | struct GNUNET_DATASTORE_QueueEntry *qe; |
483 | 482 | ||
484 | /** | 483 | /** |
484 | |||
485 | * Size of the 'bf' (in bytes). | 485 | * Size of the 'bf' (in bytes). |
486 | */ | 486 | */ |
487 | size_t bf_size; | 487 | size_t bf_size; |
@@ -2005,7 +2005,10 @@ struct ProcessReplyClosure | |||
2005 | */ | 2005 | */ |
2006 | const void *data; | 2006 | const void *data; |
2007 | 2007 | ||
2008 | // FIXME: add 'struct ConnectedPeer' to track 'last_xxx_replies' here! | 2008 | /** |
2009 | * Who gave us this reply? NULL for local host. | ||
2010 | */ | ||
2011 | struct ConnectedPeer *sender; | ||
2009 | 2012 | ||
2010 | /** | 2013 | /** |
2011 | * When the reply expires. | 2014 | * When the reply expires. |
@@ -2055,6 +2058,7 @@ process_reply (void *cls, | |||
2055 | struct ClientList *cl; | 2058 | struct ClientList *cl; |
2056 | struct PutMessage *pm; | 2059 | struct PutMessage *pm; |
2057 | struct ConnectedPeer *cp; | 2060 | struct ConnectedPeer *cp; |
2061 | struct GNUNET_TIME_Relative cur_delay; | ||
2058 | GNUNET_HashCode chash; | 2062 | GNUNET_HashCode chash; |
2059 | GNUNET_HashCode mhash; | 2063 | GNUNET_HashCode mhash; |
2060 | size_t msize; | 2064 | size_t msize; |
@@ -2069,6 +2073,33 @@ process_reply (void *cls, | |||
2069 | gettext_noop ("# replies received and matched"), | 2073 | gettext_noop ("# replies received and matched"), |
2070 | 1, | 2074 | 1, |
2071 | GNUNET_NO); | 2075 | GNUNET_NO); |
2076 | if (prq->sender != NULL) | ||
2077 | { | ||
2078 | /* FIXME: should we be more precise here and not use | ||
2079 | "start_time" but a peer-specific time stamp? */ | ||
2080 | cur_delay = GNUNET_TIME_absolute_get_duration (pr->start_time); | ||
2081 | prq->sender->avg_delay.value | ||
2082 | = (prq->sender->avg_delay.value * | ||
2083 | (RUNAVG_DELAY_N - 1) + cur_delay.value) / RUNAVG_DELAY_N; | ||
2084 | prq->sender->avg_priority | ||
2085 | = (prq->sender->avg_priority * | ||
2086 | (RUNAVG_DELAY_N - 1) + pr->priority) / (double) RUNAVG_DELAY_N; | ||
2087 | if (pr->cp != NULL) | ||
2088 | { | ||
2089 | GNUNET_PEER_change_rc (prq->sender->last_p2p_replies | ||
2090 | [prq->sender->last_p2p_replies_woff % P2P_SUCCESS_LIST_SIZE], -1); | ||
2091 | GNUNET_PEER_change_rc (pr->cp->pid, 1); | ||
2092 | prq->sender->last_p2p_replies | ||
2093 | [(prq->sender->last_p2p_replies_woff++) % P2P_SUCCESS_LIST_SIZE] | ||
2094 | = pr->cp->pid; | ||
2095 | } | ||
2096 | else | ||
2097 | { | ||
2098 | prq->sender->last_client_replies | ||
2099 | [(prq->sender->last_client_replies_woff++) % CS2P_SUCCESS_LIST_SIZE] | ||
2100 | = pr->client_request_list->client_list->client; | ||
2101 | } | ||
2102 | } | ||
2072 | GNUNET_CRYPTO_hash (prq->data, | 2103 | GNUNET_CRYPTO_hash (prq->data, |
2073 | prq->size, | 2104 | prq->size, |
2074 | &chash); | 2105 | &chash); |
@@ -2317,6 +2348,9 @@ handle_p2p_put (void *cls, | |||
2317 | GNUNET_NO); | 2348 | GNUNET_NO); |
2318 | /* now, lookup 'query' */ | 2349 | /* now, lookup 'query' */ |
2319 | prq.data = (const void*) &put[1]; | 2350 | prq.data = (const void*) &put[1]; |
2351 | if (other != NULL) | ||
2352 | prq.sender = GNUNET_CONTAINER_multihashmap_get (connected_peers, | ||
2353 | &other->hashPubKey); | ||
2320 | prq.size = dsize; | 2354 | prq.size = dsize; |
2321 | prq.type = type; | 2355 | prq.type = type; |
2322 | prq.expiration = expiration; | 2356 | prq.expiration = expiration; |
diff --git a/src/migration/Makefile.am b/src/migration/Makefile.am deleted file mode 100644 index 2bc4a1d2d..000000000 --- a/src/migration/Makefile.am +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | INCLUDES = -I$(top_srcdir)/src/include | ||
2 | |||
3 | if MINGW | ||
4 | WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols | ||
5 | endif | ||
6 | |||
7 | if USE_COVERAGE | ||
8 | AM_CFLAGS = --coverage -O0 | ||
9 | XLIBS = -lgcov | ||
10 | endif | ||
11 | |||
12 | bin_PROGRAMS = \ | ||
13 | gnunet-daemon-migration | ||
14 | |||
15 | gnunet_daemon_migration_SOURCES = \ | ||
16 | gnunet-daemon-migration.c | ||
17 | gnunet_daemon_migration_LDADD = \ | ||
18 | $(top_builddir)/src/datastore/libgnunetdatastore.la \ | ||
19 | $(top_builddir)/src/statistics/libgnunetstatistics.la \ | ||
20 | $(top_builddir)/src/core/libgnunetcore.la \ | ||
21 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
22 | $(GN_LIBINTL) | ||
23 | |||
24 | check_PROGRAMS = test_gnunet_daemon_migration | ||
25 | #TESTS = $(check_PROGRAMS) | ||
26 | |||
27 | test_gnunet_daemon_migration_SOURCES = \ | ||
28 | test_gnunet_daemon_migration.c | ||
29 | test_gnunet_daemon_migration_LDADD = \ | ||
30 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
31 | $(top_builddir)/src/util/libgnunetutil.la | ||
32 | |||
33 | EXTRA_DIST = \ | ||
34 | test_gnunet_daemon_migration_data.conf | ||
diff --git a/src/migration/gnunet-daemon-migration.c b/src/migration/gnunet-daemon-migration.c deleted file mode 100644 index 0f0dbaebc..000000000 --- a/src/migration/gnunet-daemon-migration.c +++ /dev/null | |||
@@ -1,378 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file migration/gnunet-daemon-migration.c | ||
23 | * @brief migrating (file-sharing) content through the network; this | ||
24 | * daemon is only responsible for pushing content out (not for | ||
25 | * processing inbound messages) | ||
26 | * @author Christian Grothoff | ||
27 | */ | ||
28 | #include <stdlib.h> | ||
29 | #include "platform.h" | ||
30 | #include "../fs/fs.h" | ||
31 | #include "gnunet_constants.h" | ||
32 | #include "gnunet_core_service.h" | ||
33 | #include "gnunet_datastore_service.h" | ||
34 | #include "gnunet_protocols.h" | ||
35 | #include "gnunet_statistics_service.h" | ||
36 | #include "gnunet_util_lib.h" | ||
37 | |||
38 | |||
39 | #define DEBUG_MIGRATION GNUNET_YES | ||
40 | |||
41 | /** | ||
42 | * Information we keep per peer. | ||
43 | */ | ||
44 | struct Peer | ||
45 | { | ||
46 | /** | ||
47 | * Last time we migrated data to this peer. | ||
48 | */ | ||
49 | struct GNUNET_TIME_Absolute last_migration; | ||
50 | |||
51 | }; | ||
52 | |||
53 | |||
54 | /** | ||
55 | * Our scheduler. | ||
56 | */ | ||
57 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
58 | |||
59 | /** | ||
60 | * Our configuration. | ||
61 | */ | ||
62 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | ||
63 | |||
64 | /** | ||
65 | * Handle to the core API. | ||
66 | */ | ||
67 | static struct GNUNET_CORE_Handle *handle; | ||
68 | |||
69 | /** | ||
70 | * Handle for reporting statistics. | ||
71 | */ | ||
72 | static struct GNUNET_STATISTICS_Handle *stats; | ||
73 | |||
74 | /** | ||
75 | * Handle for the core service. | ||
76 | */ | ||
77 | static struct GNUNET_CORE_Handle *handle; | ||
78 | |||
79 | /** | ||
80 | * Handle to the datastore. | ||
81 | */ | ||
82 | static struct GNUNET_DATASTORE_Handle *datastore; | ||
83 | |||
84 | /** | ||
85 | * Anonymity level for the current block. | ||
86 | */ | ||
87 | static unsigned int current_anonymity; | ||
88 | |||
89 | /** | ||
90 | * Type of the current block. | ||
91 | */ | ||
92 | static enum GNUNET_BLOCK_Type current_type; | ||
93 | |||
94 | /** | ||
95 | * Data of the current block (already encrypted). | ||
96 | */ | ||
97 | static char current_block[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | ||
98 | |||
99 | /** | ||
100 | * Size of the current block. | ||
101 | */ | ||
102 | static size_t current_block_size; | ||
103 | |||
104 | /** | ||
105 | * Key of the current block. | ||
106 | */ | ||
107 | static GNUNET_HashCode current_key; | ||
108 | |||
109 | /** | ||
110 | * Task scheduled to receive content from the datastore (with some delay). | ||
111 | */ | ||
112 | static GNUNET_SCHEDULER_TaskIdentifier get_task; | ||
113 | |||
114 | |||
115 | /** | ||
116 | * Select a peer for transmitting the current block to. | ||
117 | */ | ||
118 | static void | ||
119 | select_peer () | ||
120 | { | ||
121 | /* FIXME: select a peer for transmission... */ | ||
122 | } | ||
123 | |||
124 | |||
125 | /** | ||
126 | * Method called whenever a peer connects. | ||
127 | * | ||
128 | * @param cls closure | ||
129 | * @param peer peer identity this notification is about | ||
130 | * @param latency reported latency of the connection with 'other' | ||
131 | * @param distance reported distance (DV) to 'other' | ||
132 | */ | ||
133 | static void | ||
134 | connect_notify (void *cls, | ||
135 | const struct | ||
136 | GNUNET_PeerIdentity * peer, | ||
137 | struct GNUNET_TIME_Relative latency, | ||
138 | uint32_t distance) | ||
139 | { | ||
140 | /* FIXME: track peer */ | ||
141 | } | ||
142 | |||
143 | |||
144 | /** | ||
145 | * Method called whenever a peer disconnects. | ||
146 | * | ||
147 | * @param cls closure | ||
148 | * @param peer peer identity this notification is about | ||
149 | */ | ||
150 | static void | ||
151 | disconnect_notify (void *cls, | ||
152 | const struct | ||
153 | GNUNET_PeerIdentity * peer) | ||
154 | { | ||
155 | /* FIXME: untrack peer */ | ||
156 | } | ||
157 | |||
158 | |||
159 | /** | ||
160 | * Ask datastore for more content. | ||
161 | * @param cls closure | ||
162 | * @param tc scheduler context | ||
163 | */ | ||
164 | static void | ||
165 | get_content (void *cls, | ||
166 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
167 | |||
168 | |||
169 | /** | ||
170 | * An iterator over a set of items stored in the datastore. | ||
171 | * | ||
172 | * @param cls closure | ||
173 | * @param key key for the content | ||
174 | * @param size number of bytes in data | ||
175 | * @param data content stored | ||
176 | * @param type type of the content | ||
177 | * @param priority priority of the content | ||
178 | * @param anonymity anonymity-level for the content | ||
179 | * @param expiration expiration time for the content | ||
180 | * @param uid unique identifier for the datum; | ||
181 | * maybe 0 if no unique identifier is available | ||
182 | */ | ||
183 | static void | ||
184 | content_processor (void *cls, | ||
185 | const GNUNET_HashCode * key, | ||
186 | uint32_t size, | ||
187 | const void *data, | ||
188 | enum GNUNET_BLOCK_Type type, | ||
189 | uint32_t priority, | ||
190 | uint32_t anonymity, | ||
191 | struct GNUNET_TIME_Absolute | ||
192 | expiration, uint64_t uid) | ||
193 | { | ||
194 | if (key != NULL) | ||
195 | { | ||
196 | memcpy (current_block, data, size); | ||
197 | current_block_size = size; | ||
198 | current_type = type; | ||
199 | current_anonymity = anonymity; | ||
200 | current_key = *key; | ||
201 | return; | ||
202 | } | ||
203 | if (current_block_size == 0) | ||
204 | { | ||
205 | get_task = GNUNET_SCHEDULER_add_delayed (sched, | ||
206 | GNUNET_TIME_UNIT_MINUTES, | ||
207 | &get_content, | ||
208 | NULL); | ||
209 | return; | ||
210 | } | ||
211 | if (current_type == GNUNET_BLOCK_TYPE_ONDEMAND) | ||
212 | { | ||
213 | /* FIXME: do on-demand encoding... */ | ||
214 | return; | ||
215 | } | ||
216 | select_peer (); | ||
217 | } | ||
218 | |||
219 | |||
220 | /** | ||
221 | * Ask datastore for more content. | ||
222 | * @param cls closure | ||
223 | * @param tc scheduler context | ||
224 | */ | ||
225 | static void | ||
226 | get_content (void *cls, | ||
227 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
228 | { | ||
229 | get_task = GNUNET_SCHEDULER_NO_TASK; | ||
230 | GNUNET_DATASTORE_get_random (datastore, | ||
231 | 0, 1, | ||
232 | GNUNET_CONSTANTS_SERVICE_TIMEOUT, | ||
233 | &content_processor, | ||
234 | NULL); | ||
235 | } | ||
236 | |||
237 | |||
238 | /** | ||
239 | * Function called after GNUNET_CORE_connect has succeeded | ||
240 | * (or failed for good). | ||
241 | * | ||
242 | * @param cls closure | ||
243 | * @param server handle to the server, NULL if we failed | ||
244 | * @param my_id ID of this peer, NULL if we failed | ||
245 | * @param publicKey public key of this peer, NULL if we failed | ||
246 | */ | ||
247 | static void | ||
248 | core_init (void *cls, | ||
249 | struct GNUNET_CORE_Handle * server, | ||
250 | const struct GNUNET_PeerIdentity * | ||
251 | my_id, | ||
252 | const struct | ||
253 | GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded * | ||
254 | publicKey) | ||
255 | { | ||
256 | handle = server; | ||
257 | if (datastore != NULL) | ||
258 | get_task = GNUNET_SCHEDULER_add_now (sched, | ||
259 | &get_content, | ||
260 | NULL); | ||
261 | } | ||
262 | |||
263 | |||
264 | /** | ||
265 | * Last task run during shutdown. Disconnects us from | ||
266 | * the core. | ||
267 | * | ||
268 | * @param cls unused, NULL | ||
269 | * @param tc scheduler context | ||
270 | */ | ||
271 | static void | ||
272 | cleaning_task (void *cls, | ||
273 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
274 | { | ||
275 | if (get_task != GNUNET_SCHEDULER_NO_TASK) | ||
276 | { | ||
277 | GNUNET_SCHEDULER_cancel (sched, | ||
278 | get_task); | ||
279 | get_task = GNUNET_SCHEDULER_NO_TASK; | ||
280 | } | ||
281 | if (handle != NULL) | ||
282 | { | ||
283 | GNUNET_CORE_disconnect (handle); | ||
284 | handle = NULL; | ||
285 | } | ||
286 | if (datastore != NULL) | ||
287 | { | ||
288 | GNUNET_DATASTORE_disconnect (datastore, GNUNET_NO); | ||
289 | datastore = NULL; | ||
290 | } | ||
291 | if (stats != NULL) | ||
292 | { | ||
293 | GNUNET_STATISTICS_destroy (stats, GNUNET_NO); | ||
294 | stats = NULL; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | |||
299 | /** | ||
300 | * Main function that will be run. | ||
301 | * | ||
302 | * @param cls closure | ||
303 | * @param s the scheduler to use | ||
304 | * @param args remaining command-line arguments | ||
305 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | ||
306 | * @param c configuration | ||
307 | */ | ||
308 | static void | ||
309 | run (void *cls, | ||
310 | struct GNUNET_SCHEDULER_Handle * s, | ||
311 | char *const *args, | ||
312 | const char *cfgfile, | ||
313 | const struct GNUNET_CONFIGURATION_Handle * c) | ||
314 | { | ||
315 | struct GNUNET_CORE_MessageHandler handlers[] = | ||
316 | { | ||
317 | { NULL, 0, 0 } | ||
318 | }; | ||
319 | sched = s; | ||
320 | cfg = c; | ||
321 | stats = GNUNET_STATISTICS_create (sched, "topology", cfg); | ||
322 | handle = GNUNET_CORE_connect (sched, | ||
323 | cfg, | ||
324 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
325 | NULL, | ||
326 | &core_init, | ||
327 | &connect_notify, | ||
328 | &disconnect_notify, | ||
329 | NULL, GNUNET_NO, | ||
330 | NULL, GNUNET_NO, | ||
331 | handlers); | ||
332 | datastore = GNUNET_DATASTORE_connect (cfg, sched); | ||
333 | GNUNET_SCHEDULER_add_delayed (sched, | ||
334 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
335 | &cleaning_task, NULL); | ||
336 | if ( (NULL == handle) || | ||
337 | (NULL == datastore) ) | ||
338 | { | ||
339 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
340 | _("Failed to connect to `%s' service.\n"), | ||
341 | (NULL == handle) ? "core" : "datastore"); | ||
342 | GNUNET_SCHEDULER_shutdown (sched); | ||
343 | return; | ||
344 | } | ||
345 | } | ||
346 | |||
347 | |||
348 | /** | ||
349 | * gnunet-daemon-topology command line options. | ||
350 | */ | ||
351 | static struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
352 | GNUNET_GETOPT_OPTION_END | ||
353 | }; | ||
354 | |||
355 | |||
356 | /** | ||
357 | * The main function for the topology daemon. | ||
358 | * | ||
359 | * @param argc number of arguments from the command line | ||
360 | * @param argv command line arguments | ||
361 | * @return 0 ok, 1 on error | ||
362 | */ | ||
363 | int | ||
364 | main (int argc, char *const *argv) | ||
365 | { | ||
366 | int ret; | ||
367 | |||
368 | ret = (GNUNET_OK == | ||
369 | GNUNET_PROGRAM_run (argc, | ||
370 | argv, | ||
371 | "migration", | ||
372 | _("Content migration for anonymous file-sharing"), | ||
373 | options, | ||
374 | &run, NULL)) ? 0 : 1; | ||
375 | return ret; | ||
376 | } | ||
377 | |||
378 | /* end of gnunet-daemon-migration.c */ | ||
diff --git a/src/migration/test_gnunet_daemon_migration.c b/src/migration/test_gnunet_daemon_migration.c deleted file mode 100644 index 33cf5bb04..000000000 --- a/src/migration/test_gnunet_daemon_migration.c +++ /dev/null | |||
@@ -1,184 +0,0 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 2, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | /** | ||
21 | * @file topology/test_gnunet_daemon_migration.c | ||
22 | * @brief testcase for content migration code | ||
23 | */ | ||
24 | #include "platform.h" | ||
25 | #include "gnunet_testing_lib.h" | ||
26 | |||
27 | #define VERBOSE GNUNET_YES | ||
28 | |||
29 | #define NUM_PEERS 2 | ||
30 | |||
31 | /** | ||
32 | * How long until we give up on connecting the peers? | ||
33 | */ | ||
34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
35 | |||
36 | #define CONNECT_ATTEMPTS 3 | ||
37 | |||
38 | |||
39 | static int ok; | ||
40 | |||
41 | static int peers_left; | ||
42 | |||
43 | static int connect_left; | ||
44 | |||
45 | static struct GNUNET_TESTING_PeerGroup *pg; | ||
46 | |||
47 | static struct GNUNET_TESTING_Daemon *first; | ||
48 | |||
49 | static struct GNUNET_TESTING_Daemon *last; | ||
50 | |||
51 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
52 | |||
53 | |||
54 | static void | ||
55 | clean_up_task (void *cls, | ||
56 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
57 | { | ||
58 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT); | ||
59 | ok = 0; | ||
60 | } | ||
61 | |||
62 | |||
63 | static void | ||
64 | notify_connect_complete(void *cls, | ||
65 | const struct GNUNET_PeerIdentity *first, | ||
66 | const struct GNUNET_PeerIdentity *second, | ||
67 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | ||
68 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | ||
69 | struct GNUNET_TESTING_Daemon *first_daemon, | ||
70 | struct GNUNET_TESTING_Daemon *second_daemon, | ||
71 | const char *emsg) | ||
72 | { | ||
73 | if (NULL != emsg) | ||
74 | { | ||
75 | fprintf (stderr, | ||
76 | "Failed to connect two peers: %s\n", | ||
77 | emsg); | ||
78 | GNUNET_TESTING_daemons_stop (pg, TIMEOUT); | ||
79 | GNUNET_assert (0); | ||
80 | return; | ||
81 | } | ||
82 | connect_left--; | ||
83 | if (connect_left == 0) | ||
84 | { | ||
85 | /* FIXME: check that topology adds a few more links | ||
86 | in addition to those that were seeded */ | ||
87 | /* For now, sleep so we can have the daemon do some work */ | ||
88 | GNUNET_SCHEDULER_add_delayed (sched, | ||
89 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), | ||
90 | &clean_up_task, | ||
91 | NULL); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
96 | static void my_cb(void *cls, | ||
97 | const struct GNUNET_PeerIdentity *id, | ||
98 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
99 | struct GNUNET_TESTING_Daemon *d, | ||
100 | const char *emsg) | ||
101 | { | ||
102 | GNUNET_assert (id != NULL); | ||
103 | peers_left--; | ||
104 | if (first == NULL) | ||
105 | { | ||
106 | connect_left = NUM_PEERS; | ||
107 | first = d; | ||
108 | last = d; | ||
109 | return; | ||
110 | } | ||
111 | GNUNET_TESTING_daemons_connect (last, d, TIMEOUT, CONNECT_ATTEMPTS, | ||
112 | ¬ify_connect_complete, | ||
113 | NULL); | ||
114 | if (peers_left == 0) | ||
115 | { | ||
116 | /* close circle */ | ||
117 | GNUNET_TESTING_daemons_connect (d, first, TIMEOUT, CONNECT_ATTEMPTS, | ||
118 | ¬ify_connect_complete, | ||
119 | NULL); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | |||
124 | static void | ||
125 | run (void *cls, | ||
126 | struct GNUNET_SCHEDULER_Handle *s, | ||
127 | char *const *args, | ||
128 | const char *cfgfile, | ||
129 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
130 | { | ||
131 | sched = s; | ||
132 | ok = 1; | ||
133 | #if VERBOSE | ||
134 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
135 | "Starting daemons.\n"); | ||
136 | #endif | ||
137 | peers_left = NUM_PEERS; | ||
138 | pg = GNUNET_TESTING_daemons_start (sched, cfg, | ||
139 | peers_left, | ||
140 | TIMEOUT, | ||
141 | NULL, NULL, | ||
142 | &my_cb, NULL, NULL, NULL, NULL); | ||
143 | GNUNET_assert (pg != NULL); | ||
144 | } | ||
145 | |||
146 | static int | ||
147 | check () | ||
148 | { | ||
149 | char *const argv[] = { "test-testing", | ||
150 | "-c", | ||
151 | "test_gnunet_service_topology_data.conf", | ||
152 | #if VERBOSE | ||
153 | "-L", "DEBUG", | ||
154 | #endif | ||
155 | NULL | ||
156 | }; | ||
157 | struct GNUNET_GETOPT_CommandLineOption options[] = { | ||
158 | GNUNET_GETOPT_OPTION_END | ||
159 | }; | ||
160 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | ||
161 | argv, "test-gnunet-service-topology", "nohelp", | ||
162 | options, &run, &ok); | ||
163 | return ok; | ||
164 | } | ||
165 | |||
166 | int | ||
167 | main (int argc, char *argv[]) | ||
168 | { | ||
169 | int ret; | ||
170 | |||
171 | GNUNET_log_setup ("test-gnunet-daemon-migration", | ||
172 | #if VERBOSE | ||
173 | "DEBUG", | ||
174 | #else | ||
175 | "WARNING", | ||
176 | #endif | ||
177 | NULL); | ||
178 | ret = check (); | ||
179 | sleep (1); /* FIXME: needed? */ | ||
180 | GNUNET_DISK_directory_remove ("/tmp/test-gnunet-topology"); | ||
181 | return ret; | ||
182 | } | ||
183 | |||
184 | /* end of test_gnunet_daemon_migration.c */ | ||
diff --git a/src/migration/test_gnunet_daemon_migration_data.conf b/src/migration/test_gnunet_daemon_migration_data.conf deleted file mode 100644 index d92f9eabf..000000000 --- a/src/migration/test_gnunet_daemon_migration_data.conf +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | [PATHS] | ||
2 | SERVICEHOME = /tmp/test-gnunet-topology/ | ||
3 | # DEFAULTCONFIG = test_gnunet_service_topology_data.conf | ||
4 | |||
5 | [resolver] | ||
6 | PORT = 2664 | ||
7 | |||
8 | [transport] | ||
9 | PORT = 2665 | ||
10 | PLUGINS = tcp | ||
11 | # DEBUG = YES | ||
12 | #PREFIX = xterm -e xterm -T transport -e gdb -x cmd --args | ||
13 | #PREFIX = valgrind --tool=memcheck --log-file=logs%p | ||
14 | |||
15 | [arm] | ||
16 | PORT = 2666 | ||
17 | DEFAULTSERVICES = topology | ||
18 | |||
19 | [statistics] | ||
20 | PORT = 2667 | ||
21 | |||
22 | [transport-tcp] | ||
23 | PORT = 2668 | ||
24 | |||
25 | [peerinfo] | ||
26 | PORT = 2669 | ||
27 | |||
28 | [core] | ||
29 | PORT = 2670 | ||
30 | # DEBUG = YES | ||
31 | |||
32 | [topology] | ||
33 | # DEBUG = YES | ||
34 | #PREFIX = valgrind --tool=memcheck | ||
35 | |||
36 | [testing] | ||
37 | WEAKRANDOM = YES | ||
diff --git a/src/util/scheduler.c b/src/util/scheduler.c index c46c89500..3a646b8b7 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c | |||
@@ -613,7 +613,8 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls) | |||
613 | if (errno == EINTR) | 613 | if (errno == EINTR) |
614 | continue; | 614 | continue; |
615 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "select"); | 615 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "select"); |
616 | break; | 616 | abort (); |
617 | break; | ||
617 | } | 618 | } |
618 | if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) | 619 | if (GNUNET_NETWORK_fdset_handle_isset (rs, pr)) |
619 | { | 620 | { |