{
struct GNUNET_SERVICE_Client *client = listener->client;
+ GNUNET_MQ_destroy (listener->client_mq);
+ listener->client_mq = NULL;
+
listener->client = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting listener client\n");
GNUNET_SERVICE_client_drop (client);
return;
}
- if (NULL != listener->client_mq)
- {
- GNUNET_MQ_destroy (listener->client_mq);
- listener->client_mq = NULL;
- }
GNUNET_CADET_close_port (listener->open_port);
GNUNET_CONTAINER_DLL_remove (listeners_head,
listeners_tail,
GNUNET_free (op->spec);
op->spec = NULL;
}
- if (NULL != op->mq)
- {
- GNUNET_MQ_destroy (op->mq);
- op->mq = NULL;
- }
if (NULL != (channel = op->channel))
{
op->channel = NULL;
_GSS_operation_destroy (set->ops_head, GNUNET_NO);
set->vt->destroy_set (set->state);
set->state = NULL;
- if (NULL != set->client_mq)
- {
- GNUNET_MQ_destroy (set->client_mq);
- set->client_mq = NULL;
- }
if (NULL != set->iter)
{
GNUNET_CONTAINER_multihashmap_iterator_destroy (set->iter);
}
-/**
- * Clean up after a client has disconnected
- *
- * @param cls closure, unused
- * @param client the client to clean up after
- * @param internal_cls our client-specific internal data structure
- */
-static void
-client_disconnect_cb (void *cls,
- struct GNUNET_SERVICE_Client *client,
- void *internal_cls)
-{
- struct Listener *listener;
- struct Set *set;
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "client disconnected, cleaning up\n");
- set = set_get (client);
- if (NULL != set)
- {
- set->client = NULL;
- set_destroy (set);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's set destroyed\n");
- }
- listener = listener_get (client);
- if (NULL != listener)
- {
- listener->client = NULL;
- listener_destroy (listener);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client's listener destroyed\n");
- }
-}
-
-
/**
* Destroy an incoming request from a remote peer
*
GNUNET_free (incoming->spec);
incoming->spec = NULL;
}
- if (NULL != incoming->mq)
- {
- GNUNET_MQ_destroy (incoming->mq);
- incoming->mq = NULL;
- }
if (NULL != (channel = incoming->channel))
{
incoming->channel = NULL;
}
+/**
+ * Clean up after a client has disconnected
+ *
+ * @param cls closure, unused
+ * @param client the client to clean up after
+ * @param internal_cls our client-specific internal data structure
+ */
+static void
+client_disconnect_cb (void *cls,
+ struct GNUNET_SERVICE_Client *client,
+ void *internal_cls)
+{
+ struct Set *set;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "client disconnected, cleaning up\n");
+ set = set_get (client);
+ if (NULL != set)
+ {
+ set->client = NULL;
+ set_destroy (set);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's set destroyed\n");
+ }
+ struct Listener *listener = listener_get (client);
+ struct Operation *op = incoming_head;
+ if (NULL != listener)
+ {
+ /* destroy all incoming operations whose client just
+ * got destroyed */
+ while (NULL != op)
+ {
+ struct Operation *curr = op;
+ op = op->next;
+ if ( (GNUNET_YES == curr->is_incoming) &&
+ (curr->listener == listener) )
+ incoming_destroy (curr);
+ }
+ listener->client = NULL;
+ listener_destroy (listener);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client's listener destroyed\n");
+ }
+}
+
+
/**
* Suggest the given request to the listener. The listening client can
* then accept or reject the remote request.
listener = op->listener;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received P2P operation request (op %u, port %s) for active listener\n",
- ntohl (msg->operation),
+ (uint32_t) ntohl (msg->operation),
GNUNET_h2s (&listener->app_id));
incoming_suggest (op,
listener);
el.data = &msg[1];
el.element_type = ntohs (msg->element_type);
GNUNET_SET_element_hash (&el, &hash);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client inserts element %s of size %u\n",
- GNUNET_h2s (&hash),
- el.size);
ee = GNUNET_CONTAINER_multihashmap_get (set->content->elements,
&hash);
if (NULL == ee)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client inserts element %s of size %u\n",
+ GNUNET_h2s (&hash),
+ el.size);
ee = GNUNET_malloc (el.size + sizeof *ee);
ee->element.size = el.size;
GNUNET_memcpy (&ee[1],
}
else if (GNUNET_YES == _GSS_is_element_of_set (ee, set))
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client inserted element %s of size %u twice (ignored)\n",
+ GNUNET_h2s (&hash),
+ el.size);
+
/* same element inserted twice */
return;
}
.generation = set->current_generation,
.added = GNUNET_YES
};
- GNUNET_array_append (ee->mutations, ee->mutations_size, mut);
+ GNUNET_array_append (ee->mutations,
+ ee->mutations_size,
+ mut);
}
set->vt->add (set->state, ee);
msg = (const struct GNUNET_SET_ElementMessage *) m;
el.size = ntohs (m->size) - sizeof *msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Client removes element of size %u\n",
- el.size);
el.data = &msg[1];
el.element_type = ntohs (msg->element_type);
GNUNET_SET_element_hash (&el, &hash);
if (NULL == ee)
{
/* Client tried to remove non-existing element. */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removes non-existing element of size %u\n",
+ el.size);
return;
}
if (GNUNET_NO == _GSS_is_element_of_set (ee, set))
{
/* Client tried to remove element twice */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removed element of size %u twice (ignored)\n",
+ el.size);
return;
}
else
.generation = set->current_generation,
.added = GNUNET_NO
};
- GNUNET_array_append (ee->mutations, ee->mutations_size, mut);
+
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Client removes element of size %u\n",
+ el.size);
+
+ GNUNET_array_append (ee->mutations,
+ ee->mutations_size,
+ mut);
}
set->vt->remove (set->state, ee);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client created new set (operation %u)\n",
- ntohl (msg->operation));
+ (uint32_t) ntohl (msg->operation));
if (NULL != set_get (client))
{
/* There can only be one set per client */
incoming->is_incoming = GNUNET_YES;
incoming->peer = *source;
incoming->channel = channel;
- incoming->mq = GNUNET_CADET_mq_create (incoming->channel);
+ incoming->mq = GNUNET_CADET_get_mq (incoming->channel);
incoming->vt = &incoming_vt;
incoming->timeout_task
= GNUNET_SCHEDULER_add_delayed (INCOMING_CHANNEL_TIMEOUT,
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE,
struct GNUNET_MessageHeader,
NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL,
+ struct GNUNET_MessageHeader,
+ NULL),
GNUNET_MQ_hd_var_size (p2p_message,
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE,
struct GNUNET_MessageHeader,
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC,
struct GNUNET_MessageHeader,
NULL),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT,
+ struct GNUNET_MessageHeader,
+ NULL),
GNUNET_MQ_hd_var_size (p2p_message,
GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO,
struct GNUNET_MessageHeader,
GNUNET_MQ_handler_end ()
};
struct Listener *listener;
- struct Operation *op;
if (NULL != listener_get (client))
{
&channel_end_cb,
cadet_handlers);
/* check for existing incoming requests the listener might be interested in */
- for (op = incoming_head; NULL != op; op = op->next)
+ for (struct Operation *op = incoming_head; NULL != op; op = op->next)
{
if (NULL == op->spec)
continue; /* no details available yet */
pm = GNUNET_new (struct PendingMutation);
pm->mutation_message = GNUNET_copy_message (m);
pm->set = set;
- GNUNET_CONTAINER_DLL_insert (set->content->pending_mutations_head,
- set->content->pending_mutations_tail,
- pm);
+ GNUNET_CONTAINER_DLL_insert_tail (set->content->pending_mutations_head,
+ set->content->pending_mutations_tail,
+ pm);
return;
}
execute_mutation (set, m);
GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC,
struct GNUNET_MessageHeader,
op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL,
+ struct GNUNET_MessageHeader,
+ op),
+ GNUNET_MQ_hd_var_size (p2p_message,
+ GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT,
+ struct GNUNET_MessageHeader,
+ op),
GNUNET_MQ_hd_var_size (p2p_message,
GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO,
struct GNUNET_MessageHeader,
spec->set = set;
spec->result_mode = ntohl (msg->result_mode);
spec->client_request_id = ntohl (msg->request_id);
+ spec->byzantine = msg->byzantine;
+ spec->byzantine_lower_bound = msg->byzantine_lower_bound;
+ spec->force_full = msg->force_full;
+ spec->force_delta = msg->force_delta;
context = GNUNET_MQ_extract_nested_mh (msg);
op->spec = spec;
&channel_window_cb,
&channel_end_cb,
cadet_handlers);
- op->mq = GNUNET_CADET_mq_create (op->channel);
+ op->mq = GNUNET_CADET_get_mq (op->channel);
set->vt->evaluate (op,
context);
GNUNET_SERVICE_client_continue (client);
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client requested cancel for op %u\n",
- ntohl (msg->request_id));
+ (uint32_t) ntohl (msg->request_id));
found = GNUNET_NO;
for (op = set->ops_head; NULL != op; op = op->next)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Client accepting request %u\n",
- ntohl (msg->accept_reject_id));
+ (uint32_t) ntohl (msg->accept_reject_id));
GNUNET_assert (GNUNET_YES == op->is_incoming);
op->is_incoming = GNUNET_NO;
GNUNET_CONTAINER_DLL_remove (incoming_head,
op);
op->spec->client_request_id = ntohl (msg->request_id);
op->spec->result_mode = ntohl (msg->result_mode);
+ op->spec->byzantine = msg->byzantine;
+ op->spec->byzantine_lower_bound = msg->byzantine_lower_bound;
+ op->spec->force_full = msg->force_full;
+ op->spec->force_delta = msg->force_delta;
// Advance generation values, so that
// mutations won't interfer with the running operation.