aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2012-09-17 15:59:02 +0000
committerBart Polot <bart@net.in.tum.de>2012-09-17 15:59:02 +0000
commit701aa594eb266c5af2e54b6e30b99e909db383cb (patch)
treeb74b74b76ec18005313fca859e06a41dc8e720a4 /src
parentc74a75ecca434556774637cc72286bc4affa07b9 (diff)
downloadgnunet-701aa594eb266c5af2e54b6e30b99e909db383cb.tar.gz
gnunet-701aa594eb266c5af2e54b6e30b99e909db383cb.zip
- fix strided regex usage
Diffstat (limited to 'src')
-rw-r--r--src/mesh/gnunet-service-mesh.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c
index f6e26ceb1..c4bc561c6 100644
--- a/src/mesh/gnunet-service-mesh.c
+++ b/src/mesh/gnunet-service-mesh.c
@@ -1140,20 +1140,18 @@ tunnel_add_client (struct MeshTunnel *t, struct MeshClient *c);
1140 1140
1141 1141
1142/** 1142/**
1143 * Iterator over edges in a regex block retrieved from the DHT. 1143 * Jump to the next edge, with the longest matching token.
1144 * 1144 *
1145 * @param cls Closure. 1145 * @param block Block found in the DHT.
1146 * @param token Token that follows to next state. 1146 * @param size Size of the block.
1147 * @param len Lenght of token. 1147 * @param ctx Context of the search.
1148 * @param key Hash of next state.
1149 * 1148 *
1150 * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise. 1149 * @return GNUNET_YES if should keep iterating, GNUNET_NO otherwise.
1151 */ 1150 */
1152static int 1151static void
1153regex_edge_iterator (void *cls, 1152regex_next_edge (const struct MeshRegexBlock *block,
1154 const char *token, 1153 size_t size,
1155 size_t len, 1154 struct MeshRegexSearchContext *ctx);
1156 const struct GNUNET_HashCode *key);
1157 1155
1158 1156
1159/** 1157/**
@@ -1255,8 +1253,7 @@ regex_result_iterator (void *cls,
1255 ntohl(block->accepting)); 1253 ntohl(block->accepting));
1256 1254
1257 } 1255 }
1258 (void) GNUNET_MESH_regex_block_iterate (block, SIZE_MAX, 1256 regex_next_edge(block, SIZE_MAX, ctx);
1259 &regex_edge_iterator, ctx);
1260 1257
1261 return GNUNET_YES; 1258 return GNUNET_YES;
1262} 1259}
@@ -1310,6 +1307,10 @@ regex_edge_iterator (void *cls,
1310 ctx->longest_match = len; 1307 ctx->longest_match = len;
1311 ctx->hash = *key; 1308 ctx->hash = *key;
1312 } 1309 }
1310 else
1311 {
1312 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* Token is not longer, IGNORE\n");
1313 }
1313 1314
1314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n"); 1315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n");
1315 return GNUNET_YES; 1316 return GNUNET_YES;
@@ -1334,6 +1335,8 @@ regex_next_edge (const struct MeshRegexBlock *block,
1334 struct MeshRegexSearchInfo *info = ctx->info; 1335 struct MeshRegexSearchInfo *info = ctx->info;
1335 struct GNUNET_DHT_GetHandle *get_h; 1336 struct GNUNET_DHT_GetHandle *get_h;
1336 1337
1338 /* Find the longest match for the current string position,
1339 * among tokens in the given block */
1337 GNUNET_break (GNUNET_OK == 1340 GNUNET_break (GNUNET_OK ==
1338 GNUNET_MESH_regex_block_iterate (block, size, 1341 GNUNET_MESH_regex_block_iterate (block, size,
1339 &regex_edge_iterator, ctx)); 1342 &regex_edge_iterator, ctx));
@@ -1342,6 +1345,8 @@ regex_next_edge (const struct MeshRegexBlock *block,
1342 new_ctx->info = info; 1345 new_ctx->info = info;
1343 new_ctx->position = ctx->position + ctx->longest_match; 1346 new_ctx->position = ctx->position + ctx->longest_match;
1344 GNUNET_array_append (info->contexts, info->n_contexts, new_ctx); 1347 GNUNET_array_append (info->contexts, info->n_contexts, new_ctx);
1348
1349 /* Check whether we already have a DHT GET running for it */
1345 if (GNUNET_YES == 1350 if (GNUNET_YES ==
1346 GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, &ctx->hash)) 1351 GNUNET_CONTAINER_multihashmap_contains(info->dht_get_handles, &ctx->hash))
1347 { 1352 {
@@ -1352,6 +1357,7 @@ regex_next_edge (const struct MeshRegexBlock *block,
1352 new_ctx); 1357 new_ctx);
1353 return; // We are already looking for it 1358 return; // We are already looking for it
1354 } 1359 }
1360
1355 /* Start search in DHT */ 1361 /* Start search in DHT */
1356 get_h = 1362 get_h =
1357 GNUNET_DHT_get_start (dht_handle, /* handle */ 1363 GNUNET_DHT_get_start (dht_handle, /* handle */
@@ -6098,7 +6104,8 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
6098 const struct GNUNET_PeerIdentity *get_path, 6104 const struct GNUNET_PeerIdentity *get_path,
6099 unsigned int get_path_length, 6105 unsigned int get_path_length,
6100 const struct GNUNET_PeerIdentity *put_path, 6106 const struct GNUNET_PeerIdentity *put_path,
6101 unsigned int put_path_length, enum GNUNET_BLOCK_Type type, 6107 unsigned int put_path_length,
6108 enum GNUNET_BLOCK_Type type,
6102 size_t size, const void *data) 6109 size_t size, const void *data)
6103{ 6110{
6104 const struct MeshRegexBlock *block = data; 6111 const struct MeshRegexBlock *block = data;