summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-19 00:46:39 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-19 00:46:39 +0200
commit1eda2878cf1efef694c911c318427f14ecbdf8f3 (patch)
tree1052f9175563d001b966e430b62e7dd360b568eb
parent076acb9981bc141c7905e0dcf3f9fcda3497a8aa (diff)
-fix set/seti migration issues
-rw-r--r--src/include/gnunet_block_lib.h13
-rw-r--r--src/seti/gnunet-service-seti.c20
-rw-r--r--src/seti/plugin_block_seti_test.c44
-rw-r--r--src/seti/seti_api.c8
-rw-r--r--src/seti/test_seti.conf3
-rw-r--r--src/setu/plugin_block_setu_test.c44
6 files changed, 79 insertions, 53 deletions
diff --git a/src/include/gnunet_block_lib.h b/src/include/gnunet_block_lib.h
index 18ca6f63f..73b51252e 100644
--- a/src/include/gnunet_block_lib.h
+++ b/src/include/gnunet_block_lib.h
@@ -137,6 +137,19 @@ enum GNUNET_BLOCK_Type
* Contains either special marker elements or a nested block.
*/
GNUNET_BLOCK_TYPE_CONSENSUS_ELEMENT = 25,
+
+ /**
+ * Block for testing set intersection. If first byte of the block
+ * is non-zero, the block is considered invalid.
+ */
+ GNUNET_BLOCK_TYPE_SETI_TEST = 24,
+
+ /**
+ * Block for testing set union. If first byte of the block
+ * is non-zero, the block is considered invalid.
+ */
+ GNUNET_BLOCK_TYPE_SETU_TEST = 24,
+
};
diff --git a/src/seti/gnunet-service-seti.c b/src/seti/gnunet-service-seti.c
index 7159a7ba2..618d53128 100644
--- a/src/seti/gnunet-service-seti.c
+++ b/src/seti/gnunet-service-seti.c
@@ -519,8 +519,11 @@ send_client_removed_element (struct Operation *op,
struct GNUNET_MQ_Envelope *ev;
struct GNUNET_SETI_ResultMessage *rm;
- if (GNUNET_NO != op->return_intersection)
+ if (GNUNET_YES == op->return_intersection)
+ {
+ GNUNET_break (0);
return; /* Wrong mode for transmitting removed elements */
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Sending removed element (size %u) to client\n",
element->size);
@@ -1096,6 +1099,11 @@ send_remaining_elements (void *cls)
const struct GNUNET_SETI_Element *element;
int res;
+ if (GNUNET_NO == op->return_intersection)
+ {
+ GNUNET_break (0);
+ return; /* Wrong mode for transmitting removed elements */
+ }
res = GNUNET_CONTAINER_multihashmap_iterator_next (
op->full_result_iter,
NULL,
@@ -2191,6 +2199,7 @@ handle_client_evaluate (void *cls,
op->salt = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
UINT32_MAX);
op->peer = msg->target_peer;
+ op->return_intersection = htonl (msg->return_intersection);
op->client_request_id = ntohl (msg->request_id);
context = GNUNET_MQ_extract_nested_mh (msg);
@@ -2354,9 +2363,14 @@ handle_client_accept (void *cls,
(uint32_t) ntohl (msg->accept_reject_id));
listener = op->listener;
op->listener = NULL;
- GNUNET_CONTAINER_DLL_remove (listener->op_head, listener->op_tail, op);
+ op->return_intersection = htonl (msg->return_intersection);
+ GNUNET_CONTAINER_DLL_remove (listener->op_head,
+ listener->op_tail,
+ op);
op->set = set;
- GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op);
+ GNUNET_CONTAINER_DLL_insert (set->ops_head,
+ set->ops_tail,
+ op);
op->client_request_id = ntohl (msg->request_id);
/* Advance generation values, so that future mutations do not
diff --git a/src/seti/plugin_block_seti_test.c b/src/seti/plugin_block_seti_test.c
index 1de086092..55cf31bea 100644
--- a/src/seti/plugin_block_seti_test.c
+++ b/src/seti/plugin_block_seti_test.c
@@ -19,7 +19,7 @@
*/
/**
- * @file set/plugin_block_set_test.c
+ * @file seti/plugin_block_seti_test.c
* @brief set test block, recognizes elements with non-zero first byte as invalid
* @author Christian Grothoff
*/
@@ -46,16 +46,16 @@
* @return characterization of result
*/
static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_set_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+block_plugin_seti_test_evaluate (void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ enum GNUNET_BLOCK_EvaluationOptions eo,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
if ((NULL == reply_block) ||
(reply_block_size == 0) ||
@@ -77,11 +77,11 @@ block_plugin_set_test_evaluate (void *cls,
* (or if extracting a key from a block of this type does not work)
*/
static int
-block_plugin_set_test_get_key (void *cls,
- enum GNUNET_BLOCK_Type type,
- const void *block,
- size_t block_size,
- struct GNUNET_HashCode *key)
+block_plugin_seti_test_get_key (void *cls,
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size,
+ struct GNUNET_HashCode *key)
{
return GNUNET_SYSERR;
}
@@ -91,17 +91,17 @@ block_plugin_set_test_get_key (void *cls,
* Entry point for the plugin.
*/
void *
-libgnunet_plugin_block_set_test_init (void *cls)
+libgnunet_plugin_block_seti_test_init (void *cls)
{
static enum GNUNET_BLOCK_Type types[] = {
- GNUNET_BLOCK_TYPE_SET_TEST,
+ GNUNET_BLOCK_TYPE_SETI_TEST,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_set_test_evaluate;
- api->get_key = &block_plugin_set_test_get_key;
+ api->evaluate = &block_plugin_seti_test_evaluate;
+ api->get_key = &block_plugin_seti_test_get_key;
api->types = types;
return api;
}
@@ -111,7 +111,7 @@ libgnunet_plugin_block_set_test_init (void *cls)
* Exit point from the plugin.
*/
void *
-libgnunet_plugin_block_set_test_done (void *cls)
+libgnunet_plugin_block_seti_test_done (void *cls)
{
struct GNUNET_BLOCK_PluginFunctions *api = cls;
@@ -120,4 +120,4 @@ libgnunet_plugin_block_set_test_done (void *cls)
}
-/* end of plugin_block_set_test.c */
+/* end of plugin_block_seti_test.c */
diff --git a/src/seti/seti_api.c b/src/seti/seti_api.c
index d80a60684..337b7b219 100644
--- a/src/seti/seti_api.c
+++ b/src/seti/seti_api.c
@@ -411,7 +411,7 @@ GNUNET_SETI_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
set->cfg = cfg;
set->mq = GNUNET_CLIENT_connect (cfg,
- "set",
+ "seti",
mq_handlers,
&handle_client_set_error,
set);
@@ -549,7 +549,7 @@ GNUNET_SETI_prepare (const struct GNUNET_PeerIdentity *other_peer,
switch (opt->type)
{
case GNUNET_SETI_OPTION_RETURN_INTERSECTION:
- msg->return_intersection = GNUNET_YES;
+ msg->return_intersection = htonl (GNUNET_YES);
break;
default:
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -687,7 +687,7 @@ listen_connect (void *cls)
lh->reconnect_task = NULL;
GNUNET_assert (NULL == lh->mq);
lh->mq = GNUNET_CLIENT_connect (lh->cfg,
- "set",
+ "seti",
mq_handlers,
&handle_client_listener_error,
lh);
@@ -806,7 +806,7 @@ GNUNET_SETI_accept (struct GNUNET_SETI_Request *request,
switch (opt->type)
{
case GNUNET_SETI_OPTION_RETURN_INTERSECTION:
- oh->return_intersection = GNUNET_YES;
+ oh->return_intersection = htonl (GNUNET_YES);
break;
default:
LOG (GNUNET_ERROR_TYPE_ERROR,
diff --git a/src/seti/test_seti.conf b/src/seti/test_seti.conf
index 21fe984f8..c87433419 100644
--- a/src/seti/test_seti.conf
+++ b/src/seti/test_seti.conf
@@ -3,7 +3,7 @@
[PATHS]
GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunet-set/
-[set]
+[seti]
START_ON_DEMAND = YES
#PREFIX = valgrind --leak-check=full
#PREFIX = gdbserver :1234
@@ -30,4 +30,3 @@ DISABLEV6 = NO
# Do we use addresses from localhost address ranges? (::1, 127.0.0.0/8)
RETURN_LOCAL_ADDRESSES = YES
-
diff --git a/src/setu/plugin_block_setu_test.c b/src/setu/plugin_block_setu_test.c
index 1de086092..fd0c8a680 100644
--- a/src/setu/plugin_block_setu_test.c
+++ b/src/setu/plugin_block_setu_test.c
@@ -19,7 +19,7 @@
*/
/**
- * @file set/plugin_block_set_test.c
+ * @file setu/plugin_block_setu_test.c
* @brief set test block, recognizes elements with non-zero first byte as invalid
* @author Christian Grothoff
*/
@@ -46,16 +46,16 @@
* @return characterization of result
*/
static enum GNUNET_BLOCK_EvaluationResult
-block_plugin_set_test_evaluate (void *cls,
- struct GNUNET_BLOCK_Context *ctx,
- enum GNUNET_BLOCK_Type type,
- struct GNUNET_BLOCK_Group *group,
- enum GNUNET_BLOCK_EvaluationOptions eo,
- const struct GNUNET_HashCode *query,
- const void *xquery,
- size_t xquery_size,
- const void *reply_block,
- size_t reply_block_size)
+block_plugin_setu_test_evaluate (void *cls,
+ struct GNUNET_BLOCK_Context *ctx,
+ enum GNUNET_BLOCK_Type type,
+ struct GNUNET_BLOCK_Group *group,
+ enum GNUNET_BLOCK_EvaluationOptions eo,
+ const struct GNUNET_HashCode *query,
+ const void *xquery,
+ size_t xquery_size,
+ const void *reply_block,
+ size_t reply_block_size)
{
if ((NULL == reply_block) ||
(reply_block_size == 0) ||
@@ -77,11 +77,11 @@ block_plugin_set_test_evaluate (void *cls,
* (or if extracting a key from a block of this type does not work)
*/
static int
-block_plugin_set_test_get_key (void *cls,
- enum GNUNET_BLOCK_Type type,
- const void *block,
- size_t block_size,
- struct GNUNET_HashCode *key)
+block_plugin_setu_test_get_key (void *cls,
+ enum GNUNET_BLOCK_Type type,
+ const void *block,
+ size_t block_size,
+ struct GNUNET_HashCode *key)
{
return GNUNET_SYSERR;
}
@@ -91,17 +91,17 @@ block_plugin_set_test_get_key (void *cls,
* Entry point for the plugin.
*/
void *
-libgnunet_plugin_block_set_test_init (void *cls)
+libgnunet_plugin_block_setu_test_init (void *cls)
{
static enum GNUNET_BLOCK_Type types[] = {
- GNUNET_BLOCK_TYPE_SET_TEST,
+ GNUNET_BLOCK_TYPE_SETU_TEST,
GNUNET_BLOCK_TYPE_ANY /* end of list */
};
struct GNUNET_BLOCK_PluginFunctions *api;
api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
- api->evaluate = &block_plugin_set_test_evaluate;
- api->get_key = &block_plugin_set_test_get_key;
+ api->evaluate = &block_plugin_setu_test_evaluate;
+ api->get_key = &block_plugin_setu_test_get_key;
api->types = types;
return api;
}
@@ -111,7 +111,7 @@ libgnunet_plugin_block_set_test_init (void *cls)
* Exit point from the plugin.
*/
void *
-libgnunet_plugin_block_set_test_done (void *cls)
+libgnunet_plugin_block_setu_test_done (void *cls)
{
struct GNUNET_BLOCK_PluginFunctions *api = cls;
@@ -120,4 +120,4 @@ libgnunet_plugin_block_set_test_done (void *cls)
}
-/* end of plugin_block_set_test.c */
+/* end of plugin_block_setu_test.c */