aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fs/fs_namespace.c62
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c63
2 files changed, 112 insertions, 13 deletions
diff --git a/src/fs/fs_namespace.c b/src/fs/fs_namespace.c
index 2b3fc589f..8e13df9bc 100644
--- a/src/fs/fs_namespace.c
+++ b/src/fs/fs_namespace.c
@@ -30,6 +30,8 @@
30#include "gnunet_fs_service.h" 30#include "gnunet_fs_service.h"
31#include "fs.h" 31#include "fs.h"
32 32
33#define DEBUG_NAMESPACE GNUNET_NO
34
33/** 35/**
34 * Return the name of the directory in which we store 36 * Return the name of the directory in which we store
35 * our local namespaces (or rather, their public keys). 37 * our local namespaces (or rather, their public keys).
@@ -1095,6 +1097,8 @@ find_sccs (void *cls,
1095 { 1097 {
1096 if (fc->scc_array[nsn->scc_id] != nsn) 1098 if (fc->scc_array[nsn->scc_id] != nsn)
1097 return GNUNET_YES; /* part of another SCC, end trace */ 1099 return GNUNET_YES; /* part of another SCC, end trace */
1100 if (nsn->scc_id == fc->id)
1101 return GNUNET_YES; /* that's us */
1098 fc->scc_array[nsn->scc_id] = NULL; 1102 fc->scc_array[nsn->scc_id] = NULL;
1099 if (fc->id == UINT_MAX) 1103 if (fc->id == UINT_MAX)
1100 fc->id = nsn->scc_id; /* take over ID */ 1104 fc->id = nsn->scc_id; /* take over ID */
@@ -1151,7 +1155,14 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1151 if (namespace->update_nodes == NULL) 1155 if (namespace->update_nodes == NULL)
1152 read_update_information_graph (namespace); 1156 read_update_information_graph (namespace);
1153 if (namespace->update_nodes == NULL) 1157 if (namespace->update_nodes == NULL)
1154 return; /* no nodes */ 1158 {
1159#if DEBUG_NAMESPACE
1160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1161 "No updateable nodes found for ID `%s'\n",
1162 next_id);
1163#endif
1164 return; /* no nodes */
1165 }
1155 if (namespace->update_map == NULL) 1166 if (namespace->update_map == NULL)
1156 { 1167 {
1157 /* need to construct */ 1168 /* need to construct */
@@ -1181,6 +1192,10 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1181 &pc); 1192 &pc);
1182 return; 1193 return;
1183 } 1194 }
1195#if DEBUG_NAMESPACE
1196 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1197 "Calculating SCCs to find roots of update trees\n");
1198#endif
1184 /* Find heads of SCCs in update graph */ 1199 /* Find heads of SCCs in update graph */
1185 nug = ++namespace->nug_gen; 1200 nug = ++namespace->nug_gen;
1186 fc.scc_array = NULL; 1201 fc.scc_array = NULL;
@@ -1190,7 +1205,15 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1190 { 1205 {
1191 nsn = namespace->update_nodes[i]; 1206 nsn = namespace->update_nodes[i];
1192 if (nsn->nug == nug) 1207 if (nsn->nug == nug)
1193 continue; /* already placed in SCC */ 1208 {
1209#if DEBUG_NAMESPACE
1210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1211 "SCC of node `%s' is %u\n",
1212 nsn->id,
1213 nsn->nug);
1214#endif
1215 continue; /* already placed in SCC */
1216 }
1194 GNUNET_CRYPTO_hash (nsn->update, 1217 GNUNET_CRYPTO_hash (nsn->update,
1195 strlen (nsn->update), 1218 strlen (nsn->update),
1196 &hc); 1219 &hc);
@@ -1221,6 +1244,12 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1221 nsn); 1244 nsn);
1222 nsn->scc_id = fc.id; 1245 nsn->scc_id = fc.id;
1223 } 1246 }
1247#if DEBUG_NAMESPACE
1248 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1249 "Starting new SCC %u with node `%s'\n",
1250 nsn->scc_id,
1251 nsn->id);
1252#endif
1224 /* put all nodes with same identifier into this SCC */ 1253 /* put all nodes with same identifier into this SCC */
1225 GNUNET_CRYPTO_hash (nsn->id, 1254 GNUNET_CRYPTO_hash (nsn->id,
1226 strlen (nsn->id), 1255 strlen (nsn->id),
@@ -1239,20 +1268,39 @@ GNUNET_FS_namespace_list_updateable (struct GNUNET_FS_Namespace *namespace,
1239 fc.scc_array[fc.id] = nsn; 1268 fc.scc_array[fc.id] = nsn;
1240 nsn->scc_id = fc.id; 1269 nsn->scc_id = fc.id;
1241 } 1270 }
1271#if DEBUG_NAMESPACE
1272 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1273 "SCC of node `%s' is %u\n",
1274 nsn->id,
1275 fc.id);
1276#endif
1242 } 1277 }
1243 for (i=0;i<fc.scc_array_size;i++) 1278 for (i=0;i<fc.scc_array_size;i++)
1244 { 1279 {
1245 nsn = fc.scc_array[i]; 1280 nsn = fc.scc_array[i];
1246 if (NULL != nsn) 1281 if (NULL != nsn)
1247 ip (ip_cls, 1282 {
1248 nsn->id, 1283#if DEBUG_NAMESPACE
1249 nsn->uri, 1284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1250 nsn->md, 1285 "Root of SCC %u is node `%s'\n",
1251 nsn->update); 1286 i,
1287 nsn->id);
1288#endif
1289
1290 ip (ip_cls,
1291 nsn->id,
1292 nsn->uri,
1293 nsn->md,
1294 nsn->update);
1295 }
1252 } 1296 }
1253 GNUNET_array_grow (fc.scc_array, 1297 GNUNET_array_grow (fc.scc_array,
1254 fc.scc_array_size, 1298 fc.scc_array_size,
1255 0); 1299 0);
1300#if DEBUG_NAMESPACE
1301 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1302 "Done processing SCCs\n");
1303#endif
1256} 1304}
1257 1305
1258 1306
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index c2351471e..fc6b1537a 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -19,12 +19,9 @@
19*/ 19*/
20 20
21/** 21/**
22 * @file fs/test_fs_namespace.c 22 * @file fs/test_fs_namespace_list_updateable.c
23 * @brief Test for fs_namespace.c 23 * @brief Test for fs_namespace_list_updateable.c
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 *
26 * TODO:
27 * - add timeout task
28 */ 25 */
29#include "platform.h" 26#include "platform.h"
30#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
@@ -112,11 +109,61 @@ stop_arm (struct PeerContext *p)
112 109
113 110
114static void 111static void
112check_next (void *cls,
113 const char *last_id,
114 const struct GNUNET_FS_Uri *last_uri,
115 const struct GNUNET_CONTAINER_MetaData *last_meta,
116 const char *next_id)
117{
118 GNUNET_break (0 == strcmp (last_id, "next"));
119 GNUNET_break (0 == strcmp (next_id, "future"));
120 err -= 4;
121}
122
123
124static void
125check_this_next (void *cls,
126 const char *last_id,
127 const struct GNUNET_FS_Uri *last_uri,
128 const struct GNUNET_CONTAINER_MetaData *last_meta,
129 const char *next_id)
130{
131 GNUNET_break (0 == strcmp (last_id, "this"));
132 GNUNET_break (0 == strcmp (next_id, "next"));
133 err -= 2;
134 err += 4;
135 GNUNET_FS_namespace_list_updateable (ns,
136 next_id,
137 &check_next,
138 NULL);
139}
140
141
142static void
115sks_cont_next (void *cls, 143sks_cont_next (void *cls,
116 const struct GNUNET_FS_Uri *uri, 144 const struct GNUNET_FS_Uri *uri,
117 const char *emsg) 145 const char *emsg)
118{ 146{
119 GNUNET_assert (NULL == emsg); 147 GNUNET_assert (NULL == emsg);
148 err += 2;
149 GNUNET_FS_namespace_list_updateable (ns,
150 NULL,
151 &check_this_next,
152 NULL);
153
154}
155
156
157static void
158check_this (void *cls,
159 const char *last_id,
160 const struct GNUNET_FS_Uri *last_uri,
161 const struct GNUNET_CONTAINER_MetaData *last_meta,
162 const char *next_id)
163{
164 GNUNET_break (0 == strcmp (last_id, "this"));
165 GNUNET_break (0 == strcmp (next_id, "next"));
166 err -= 1;
120} 167}
121 168
122 169
@@ -126,7 +173,11 @@ sks_cont_this (void *cls,
126 const char *emsg) 173 const char *emsg)
127{ 174{
128 GNUNET_assert (NULL == emsg); 175 GNUNET_assert (NULL == emsg);
129 176 err = 1;
177 GNUNET_FS_namespace_list_updateable (ns,
178 NULL,
179 &check_this,
180 NULL);
130 GNUNET_FS_publish_sks (fs, 181 GNUNET_FS_publish_sks (fs,
131 ns, 182 ns,
132 "next", 183 "next",