aboutsummaryrefslogtreecommitdiff
path: root/src/fs/fs_namespace.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-09-05 21:48:41 +0000
committerChristian Grothoff <christian@grothoff.org>2010-09-05 21:48:41 +0000
commit7749caa5dbd33bc337675ccc38e08213ef46ddcc (patch)
tree42ef890b1a91bbbadad4d9162c15fac15e1611d0 /src/fs/fs_namespace.c
parentba8ca593c236036cfeaa0b1bafd6a79c851017d8 (diff)
downloadgnunet-7749caa5dbd33bc337675ccc38e08213ef46ddcc.tar.gz
gnunet-7749caa5dbd33bc337675ccc38e08213ef46ddcc.zip
fix
Diffstat (limited to 'src/fs/fs_namespace.c')
-rw-r--r--src/fs/fs_namespace.c62
1 files changed, 55 insertions, 7 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