two-peer set operations More...
#include "platform.h"
#include "gnunet-service-set.h"
#include "gnunet-service-set_union.h"
#include "gnunet-service-set_intersection.h"
#include "gnunet-service-set_protocol.h"
#include "gnunet_statistics_service.h"
Go to the source code of this file.
Data Structures | |
struct | LazyCopyRequest |
Lazy copy requests made by a client. More... | |
struct | Listener |
A listener is inhabited by a client, and waits for evaluation requests from remote peers. More... | |
struct | GarbageContext |
Context for the garbage_collect_cb(). More... | |
Macros | |
#define | INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we hold on to an incoming channel if there is no local listener before giving up? More... | |
Functions | |
static struct Operation * | get_incoming (uint32_t id) |
Get the incoming socket associated with the given id. More... | |
static void | incoming_destroy (struct Operation *op) |
Destroy an incoming request from a remote peer. More... | |
static int | garbage_collect_cb (void *cls, const struct GNUNET_HashCode *key, void *value) |
Function invoked to check if an element can be removed from the set's history because it is no longer needed. More... | |
static void | collect_generation_garbage (struct Set *set) |
Collect and destroy elements that are not needed anymore, because their lifetime (as determined by their generation) does not overlap with any active set operation. More... | |
static int | is_excluded_generation (unsigned int generation, struct GenerationRange *excluded, unsigned int excluded_size) |
Is generation in the range of exclusions? More... | |
static int | is_element_of_generation (struct ElementEntry *ee, unsigned int query_generation, struct GenerationRange *excluded, unsigned int excluded_size) |
Is element ee part of the set during query_generation? More... | |
int | _GSS_is_element_of_operation (struct ElementEntry *ee, struct Operation *op) |
Is element ee part of the set used by op? More... | |
void | _GSS_operation_destroy (struct Operation *op, int gc) |
Destroy the given operation. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) |
Callback called when a client connects to the service. More... | |
static int | destroy_elements_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
Iterator over hash map entries to free element entries. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *internal_cls) |
Clean up after a client has disconnected. More... | |
static int | check_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
Check a request for a set operation from another peer. More... | |
static void | handle_incoming_msg (void *cls, const struct OperationRequestMessage *msg) |
Handle a request for a set operation from another peer. More... | |
static void | execute_add (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
Add an element to set as specified by msg. More... | |
static void | execute_remove (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
Remove an element from set as specified by msg. More... | |
static void | execute_mutation (struct Set *set, const struct GNUNET_SET_ElementMessage *msg) |
Perform a mutation on a set as specified by the msg. More... | |
static void | execute_delayed_mutations (struct Set *set) |
Execute mutations that were delayed on a set because of pending operations. More... | |
static void | send_client_element (struct Set *set) |
Send the next element of a set to the set's client. More... | |
static void | handle_client_iterate (void *cls, const struct GNUNET_MessageHeader *m) |
Called when a client wants to iterate the elements of a set. More... | |
static void | handle_client_create_set (void *cls, const struct GNUNET_SET_CreateMessage *msg) |
Called when a client wants to create a new set. More... | |
static void | incoming_timeout_cb (void *cls) |
Timeout happens iff: More... | |
static void * | channel_new_cb (void *cls, struct GNUNET_CADET_Channel *channel, const struct GNUNET_PeerIdentity *source) |
Method called whenever another peer has added us to a channel the other peer initiated. More... | |
static void | channel_end_cb (void *channel_ctx, const struct GNUNET_CADET_Channel *channel) |
Function called whenever a channel is destroyed. More... | |
void | _GSS_operation_destroy2 (struct Operation *op) |
This function probably should not exist and be replaced by inlining more specific logic in the various places where it is called. More... | |
static void | channel_window_cb (void *cls, const struct GNUNET_CADET_Channel *channel, int window_size) |
Function called whenever an MQ-channel's transmission window size changes. More... | |
static void | handle_client_listen (void *cls, const struct GNUNET_SET_ListenMessage *msg) |
Called when a client wants to create a new listener. More... | |
static void | handle_client_reject (void *cls, const struct GNUNET_SET_RejectMessage *msg) |
Called when the listening client rejects an operation request by another peer. More... | |
static int | check_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
Called when a client wants to add or remove an element to a set it inhabits. More... | |
static void | handle_client_mutation (void *cls, const struct GNUNET_SET_ElementMessage *msg) |
Called when a client wants to add or remove an element to a set it inhabits. More... | |
static void | advance_generation (struct Set *set) |
Advance the current generation of a set, adding exclusion ranges if necessary. More... | |
static int | check_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
Called when a client wants to initiate a set operation with another peer. More... | |
static void | handle_client_evaluate (void *cls, const struct GNUNET_SET_EvaluateMessage *msg) |
Called when a client wants to initiate a set operation with another peer. More... | |
static void | handle_client_iter_ack (void *cls, const struct GNUNET_SET_IterAckMessage *ack) |
Handle an ack from a client, and send the next element. More... | |
static void | handle_client_copy_lazy_prepare (void *cls, const struct GNUNET_MessageHeader *mh) |
Handle a request from the client to copy a set. More... | |
static void | handle_client_copy_lazy_connect (void *cls, const struct GNUNET_SET_CopyLazyConnectMessage *msg) |
Handle a request from the client to connect to a copy of a set. More... | |
static void | handle_client_cancel (void *cls, const struct GNUNET_SET_CancelMessage *msg) |
Handle a request from the client to cancel a running set operation. More... | |
static void | handle_client_accept (void *cls, const struct GNUNET_SET_AcceptMessage *msg) |
Handle a request from the client to accept a set operation that came from a remote peer. More... | |
static void | shutdown_task (void *cls) |
Called to clean up, after a shutdown has been requested. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service) |
Function called by the service's run method to run service-specific setup code. More... | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "set", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(client_accept, GNUNET_MESSAGE_TYPE_SET_ACCEPT, struct GNUNET_SET_AcceptMessage, NULL), GNUNET_MQ_hd_fixed_size(client_iter_ack, GNUNET_MESSAGE_TYPE_SET_ITER_ACK, struct GNUNET_SET_IterAckMessage, NULL), GNUNET_MQ_hd_var_size(client_mutation, GNUNET_MESSAGE_TYPE_SET_ADD, struct GNUNET_SET_ElementMessage, NULL), GNUNET_MQ_hd_fixed_size(client_create_set, GNUNET_MESSAGE_TYPE_SET_CREATE, struct GNUNET_SET_CreateMessage, NULL), GNUNET_MQ_hd_fixed_size(client_iterate, GNUNET_MESSAGE_TYPE_SET_ITER_REQUEST, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(client_evaluate, GNUNET_MESSAGE_TYPE_SET_EVALUATE, struct GNUNET_SET_EvaluateMessage, NULL), GNUNET_MQ_hd_fixed_size(client_listen, GNUNET_MESSAGE_TYPE_SET_LISTEN, struct GNUNET_SET_ListenMessage, NULL), GNUNET_MQ_hd_fixed_size(client_reject, GNUNET_MESSAGE_TYPE_SET_REJECT, struct GNUNET_SET_RejectMessage, NULL), GNUNET_MQ_hd_var_size(client_mutation, GNUNET_MESSAGE_TYPE_SET_REMOVE, struct GNUNET_SET_ElementMessage, NULL), GNUNET_MQ_hd_fixed_size(client_cancel, GNUNET_MESSAGE_TYPE_SET_CANCEL, struct GNUNET_SET_CancelMessage, NULL), GNUNET_MQ_hd_fixed_size(client_copy_lazy_prepare, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_PREPARE, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_fixed_size(client_copy_lazy_connect, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_CONNECT, struct GNUNET_SET_CopyLazyConnectMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static struct GNUNET_CADET_Handle * | cadet |
Handle to the cadet service, used to listen for and connect to remote peers. More... | |
static struct LazyCopyRequest * | lazy_copy_head |
DLL of lazy copy requests by this client. More... | |
static struct LazyCopyRequest * | lazy_copy_tail |
DLL of lazy copy requests by this client. More... | |
static uint32_t | lazy_copy_cookie |
Generator for unique cookie we set per lazy copy request. More... | |
struct GNUNET_STATISTICS_Handle * | _GSS_statistics |
Statistics handle. More... | |
static struct Listener * | listener_head |
Listeners are held in a doubly linked list. More... | |
static struct Listener * | listener_tail |
Listeners are held in a doubly linked list. More... | |
static unsigned int | num_clients |
Number of active clients. More... | |
static int | in_shutdown |
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET. More... | |
static uint32_t | suggest_id |
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remote peers, that the client can choose to accept or refuse. More... | |
two-peer set operations
Definition in file gnunet-service-set.c.
#define INCOMING_CHANNEL_TIMEOUT GNUNET_TIME_UNIT_MINUTES |
How long do we hold on to an incoming channel if there is no local listener before giving up?
Definition at line 37 of file gnunet-service-set.c.
|
static |
Get the incoming socket associated with the given id.
id | id to look for |
Definition at line 185 of file gnunet-service-set.c.
References Operation::listener, listener_head, Listener::next, GNUNET_ARM_Operation::next, op, and Listener::op_head.
Referenced by handle_client_accept(), and handle_client_reject().
|
static |
Destroy an incoming request from a remote peer.
op | remote request to destroy |
Definition at line 204 of file gnunet-service-set.c.
References _GSS_operation_destroy2(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SCHEDULER_cancel(), op, Listener::op_head, and Listener::op_tail.
Referenced by _GSS_operation_destroy2(), client_disconnect_cb(), and incoming_timeout_cb().
|
static |
Function invoked to check if an element can be removed from the set's history because it is no longer needed.
cls | the struct GarbageContext * |
key | key of the element in the map |
value | the struct ElementEntry * |
Definition at line 257 of file gnunet-service-set.c.
References GNUNET_OK.
Referenced by collect_generation_garbage().
|
static |
Collect and destroy elements that are not needed anymore, because their lifetime (as determined by their generation) does not overlap with any active set operation.
set | set to garbage collect |
Definition at line 285 of file gnunet-service-set.c.
References Set::content, SetContent::elements, garbage_collect_cb(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_MAX, GNUNET_MIN, GarbageContext::map, GarbageContext::max_op_generation, GarbageContext::min_op_generation, GNUNET_ARM_Operation::next, op, and Set::ops_head.
Referenced by _GSS_operation_destroy().
|
static |
Is generation in the range of exclusions?
generation | generation to query |
excluded | array of generations where the element is excluded |
excluded_size | length of the excluded array |
Definition at line 314 of file gnunet-service-set.c.
References end, GNUNET_NO, GNUNET_YES, and start.
Referenced by is_element_of_generation().
|
static |
Is element ee part of the set during query_generation?
ee | element to test |
query_generation | generation to query |
excluded | array of generations where the element is excluded |
excluded_size | length of the excluded array |
Definition at line 335 of file gnunet-service-set.c.
References MutationEvent::added, MutationEvent::generation, GNUNET_assert, GNUNET_break, GNUNET_NO, GNUNET_YES, is_excluded_generation(), ElementEntry::mutations, and ElementEntry::mutations_size.
Referenced by _GSS_is_element_of_operation(), execute_add(), execute_remove(), and send_client_element().
int _GSS_is_element_of_operation | ( | struct ElementEntry * | ee, |
struct Operation * | op | ||
) |
Is element ee part of the set used by op?
ee | element to test |
op | operation the defines the set and its generation |
Definition at line 398 of file gnunet-service-set.c.
References is_element_of_generation(), and op.
Referenced by filtered_map_initialization(), handle_union_p2p_demand(), handle_union_p2p_offer(), init_key_to_element_iterator(), and initialize_map_unfiltered().
void _GSS_operation_destroy | ( | struct Operation * | op, |
int | gc | ||
) |
Destroy the given operation.
Used for any operation where both peers were known and that thus actually had a vt and channel. Must not be used for operations where 'listener' is still set and we do not know the other peer.
Call the implementation-specific cancel function of the operation. Disconnects from the remote peer. Does not disconnect the client, as there may be multiple operations per set.
op | operation to destroy |
gc | GNUNET_YES to perform garbage collection on the set |
Definition at line 421 of file gnunet-service-set.c.
References SetVT::cancel, collect_generation_garbage(), GNUNET_assert, GNUNET_CADET_channel_destroy(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, op, Set::ops_head, Set::ops_tail, and Set::vt.
Referenced by _GSS_operation_destroy2(), client_disconnect_cb(), fail_intersection_operation(), fail_union_operation(), handle_client_cancel(), intersection_channel_death(), send_client_done_and_destroy(), and union_channel_death().
|
static |
Callback called when a client connects to the service.
cls | closure for the service |
c | the new client that connected to the service |
mq | the message queue used to send messages to the client |
Definition at line 466 of file gnunet-service-set.c.
References ClientState::client, GNUNET_new, mq, ClientState::mq, and num_clients.
|
static |
Iterator over hash map entries to free element entries.
cls | closure |
key | current key code |
value | a struct ElementEntry * to be free'd |
Definition at line 489 of file gnunet-service-set.c.
References GNUNET_free, GNUNET_YES, ElementEntry::mutations, and value.
Referenced by client_disconnect_cb().
|
static |
Clean up after a client has disconnected.
cls | closure, unused |
client | the client to clean up after |
internal_cls | the struct ClientState |
Definition at line 509 of file gnunet-service-set.c.
References _GSS_operation_destroy(), cadet, Set::content, Set::cs, destroy_elements_iterator(), SetVT::destroy_set, SetContent::elements, Set::excluded_generations, GNUNET_assert, GNUNET_CADET_close_port(), GNUNET_CADET_disconnect(), GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap_destroy(), GNUNET_CONTAINER_multihashmap_iterate(), GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_NO, GNUNET_YES, in_shutdown, incoming_destroy(), Set::iter, Set::iteration_id, lazy_copy_head, lazy_copy_tail, ClientState::listener, listener_head, listener_tail, LazyCopyRequest::next, num_clients, op, Listener::op_head, Listener::open_port, Set::ops_head, SetContent::pending_mutations_head, SetContent::pending_mutations_tail, pm, SetContent::refcount, ClientState::set, PendingMutation::set, LazyCopyRequest::source_set, Set::state, and Set::vt.
|
static |
Check a request for a set operation from another peer.
cls | the operation state |
msg | the received message |
Definition at line 632 of file gnunet-service-set.c.
References GNUNET_break, GNUNET_break_op, GNUNET_MQ_extract_nested_mh, GNUNET_OK, GNUNET_SET_CONTEXT_MESSAGE_MAX_SIZE, GNUNET_SYSERR, msg, op, Listener::operation, and GNUNET_MessageHeader::size.
|
static |
Handle a request for a set operation from another peer.
Checks if we have a listener waiting for such a request (and in that case initiates asking the listener about accepting the connection). If no listener is waiting, we queue the operation request in hope that a listener shows up soon (before timeout).
This msg is expected as the first and only msg handled through the non-operation bound virtual table, acceptance of this operation replaces our virtual table and subsequent msgs would be routed differently (as we then know what type of operation this is).
cls | the operation state |
msg | the received message |
Definition at line 684 of file gnunet-service-set.c.
References GNUNET_SET_RequestMessage::accept_id, Listener::cs, env, GNUNET_assert, GNUNET_copy_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SET_REQUEST, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_msg_nested_mh, GNUNET_MQ_send(), GNUNET_SCHEDULER_cancel(), ClientState::mq, msg, op, GNUNET_SET_RequestMessage::peer_id, and suggest_id.
|
static |
Add an element to set as specified by msg.
set | set to manipulate |
msg | message specifying the change |
Definition at line 735 of file gnunet-service-set.c.
References SetVT::add, Set::content, Set::current_generation, GNUNET_SET_Element::data, el, ElementEntry::element, ElementEntry::element_hash, GNUNET_SET_Element::element_type, SetContent::elements, Set::excluded_generations, Set::excluded_generations_size, MutationEvent::generation, GNUNET_array_append, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap_get(), GNUNET_CONTAINER_multihashmap_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_malloc, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_ADD, GNUNET_NO, GNUNET_SET_element_hash(), GNUNET_YES, is_element_of_generation(), msg, ElementEntry::mutations, ElementEntry::mutations_size, ElementEntry::remote, GNUNET_MessageHeader::size, GNUNET_SET_Element::size, Set::state, GNUNET_MessageHeader::type, and Set::vt.
Referenced by execute_mutation().
|
static |
Remove an element from set as specified by msg.
set | set to manipulate |
msg | message specifying the change |
Definition at line 800 of file gnunet-service-set.c.
References Set::content, Set::current_generation, el, SetContent::elements, Set::excluded_generations, Set::excluded_generations_size, MutationEvent::generation, GNUNET_array_append, GNUNET_assert, GNUNET_CONTAINER_multihashmap_get(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_SET_REMOVE, GNUNET_NO, GNUNET_SET_element_hash(), is_element_of_generation(), msg, ElementEntry::mutations, ElementEntry::mutations_size, SetVT::remove, GNUNET_MessageHeader::size, Set::state, GNUNET_MessageHeader::type, and Set::vt.
Referenced by execute_mutation().
|
static |
Perform a mutation on a set as specified by the msg.
set | the set to mutate |
msg | specification of what to change |
Definition at line 853 of file gnunet-service-set.c.
References execute_add(), execute_remove(), GNUNET_break, GNUNET_MESSAGE_TYPE_SET_ADD, GNUNET_MESSAGE_TYPE_SET_REMOVE, msg, and GNUNET_MessageHeader::type.
Referenced by execute_delayed_mutations(), and handle_client_mutation().
|
static |
Execute mutations that were delayed on a set because of pending operations.
set | the set to execute mutations on |
Definition at line 878 of file gnunet-service-set.c.
References Set::content, execute_mutation(), GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, SetContent::iterator_count, SetContent::pending_mutations_head, SetContent::pending_mutations_tail, pm, and PendingMutation::set.
Referenced by send_client_element().
|
static |
Send the next element of a set to the set's client.
The next element is given by the set's current hashmap iterator. The set's iterator will be set to NULL if there are no more elements in the set. The caller must ensure that the set's iterator is valid.
The client will acknowledge each received element with a GNUNET_MESSAGE_TYPE_SET_ITER_ACK message. Our handle_client_iter_ack() will then trigger the next transmission. Note that the GNUNET_MESSAGE_TYPE_SET_ITER_DONE is not acknowledged.
set | set that should send its next element to its client |
Definition at line 913 of file gnunet-service-set.c.
References Set::content, Set::cs, GNUNET_SET_Element::data, ElementEntry::element, GNUNET_SET_Element::element_type, Set::excluded_generations, Set::excluded_generations_size, execute_delayed_mutations(), GNUNET_assert, GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_CONTAINER_multihashmap_iterator_next(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_SET_ITER_DONE, GNUNET_MESSAGE_TYPE_SET_ITER_ELEMENT, GNUNET_MQ_msg_extra, GNUNET_MQ_msg_header, GNUNET_MQ_send(), GNUNET_NO, is_element_of_generation(), Set::iter, Set::iter_generation, Set::iteration_id, SetContent::iterator_count, ClientState::mq, msg, ret, and GNUNET_SET_Element::size.
Referenced by handle_client_iter_ack(), and handle_client_iterate().
|
static |
Called when a client wants to iterate the elements of a set.
Checks if we have a set associated with the client and if we can right now start an iteration. If all checks out, starts sending the elements of the set to the client.
cls | client that sent the message |
m | message sent by the client |
Definition at line 969 of file gnunet-service-set.c.
References ClientState::client, Set::content, Set::cs, Set::current_generation, SetContent::elements, GNUNET_break, GNUNET_CONTAINER_multihashmap_iterator_create(), GNUNET_CONTAINER_multihashmap_size(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), Set::iter, Set::iter_generation, SetContent::iterator_count, send_client_element(), and ClientState::set.
|
static |
Called when a client wants to create a new set.
This is typically the first request from a client, and includes the type of set operation to be performed.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1011 of file gnunet-service-set.c.
References _GSS_intersection_vt(), _GSS_union_vt(), ClientState::client, Set::content, SetVT::create, Set::cs, SetContent::elements, GNUNET_break, GNUNET_CONTAINER_multihashmap_create(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SET_OPERATION_INTERSECTION, GNUNET_SET_OPERATION_UNION, GNUNET_YES, msg, Set::operation, SetContent::refcount, ClientState::set, Set::state, and Set::vt.
|
static |
Timeout happens iff:
cls | channel context |
Definition at line 1070 of file gnunet-service-set.c.
References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, incoming_destroy(), and op.
Referenced by channel_new_cb().
|
static |
Method called whenever another peer has added us to a channel the other peer initiated.
Only called (once) upon reception of data from a channel we listen on.
The channel context represents the operation itself and gets added to a DLL, from where it gets looked up when our local listener client responds to a proposed/suggested operation or connects and associates with this operation.
cls | closure |
channel | new handle to the channel |
source | peer that started the channel |
Definition at line 1098 of file gnunet-service-set.c.
References Operation::channel, GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SCHEDULER_add_delayed(), INCOMING_CHANNEL_TIMEOUT, incoming_timeout_cb(), Operation::listener, op, Listener::op_head, Listener::op_tail, and source.
Referenced by handle_client_listen().
|
static |
Function called whenever a channel is destroyed.
Should clean up any associated state. It must NOT call GNUNET_CADET_channel_destroy() on the channel.
The peer_disconnect function is part of a a virtual table set initially either when a peer creates a new channel with us, or once we create a new channel ourselves (evaluate).
Once we know the exact type of operation (union/intersection), the vt is replaced with an operation specific instance (GSS[op]_vt).
channel_ctx | place where local state associated with the channel is stored |
channel | connection to the other end (henceforth invalid) |
Definition at line 1137 of file gnunet-service-set.c.
References _GSS_operation_destroy2(), and op.
Referenced by handle_client_evaluate(), and handle_client_listen().
static void _GSS_operation_destroy2 | ( | struct Operation * | op | ) |
This function probably should not exist and be replaced by inlining more specific logic in the various places where it is called.
Definition at line 1152 of file gnunet-service-set.c.
References _GSS_operation_destroy(), GNUNET_CADET_channel_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_YES, incoming_destroy(), and op.
Referenced by channel_end_cb(), handle_client_reject(), handle_union_p2p_full_done(), incoming_destroy(), and maybe_finish().
|
static |
Function called whenever an MQ-channel's transmission window size changes.
The first callback in an outgoing channel will be with a non-zero value and will mean the channel is connected to the destination.
For an incoming channel it will be called immediately after the GNUNET_CADET_ConnectEventHandler, also with a non-zero value.
cls | Channel closure. |
channel | Connection to the other end (henceforth invalid). |
window_size | New window size. If the is more messages than buffer size this value will be negative.. |
Definition at line 1192 of file gnunet-service-set.c.
Referenced by handle_client_evaluate(), and handle_client_listen().
|
static |
Called when a client wants to create a new listener.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1207 of file gnunet-service-set.c.
References Listener::app_id, cadet, channel_end_cb(), channel_new_cb(), channel_window_cb(), ClientState::client, Listener::cs, GNUNET_break, GNUNET_CADET_open_port(), GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), ClientState::listener, listener_head, listener_tail, msg, Listener::open_port, and Listener::operation.
|
static |
Called when the listening client rejects an operation request by another peer.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1314 of file gnunet-service-set.c.
References _GSS_operation_destroy2(), Listener::app_id, ClientState::client, get_incoming(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_h2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), ClientState::listener, msg, and op.
|
static |
Called when a client wants to add or remove an element to a set it inhabits.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1346 of file gnunet-service-set.c.
References GNUNET_OK.
|
static |
Called when a client wants to add or remove an element to a set it inhabits.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1361 of file gnunet-service-set.c.
References ClientState::client, Set::content, Set::cs, execute_mutation(), GNUNET_break, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_copy_message(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), SetContent::iterator_count, msg, SetContent::pending_mutations_head, SetContent::pending_mutations_tail, pm, and ClientState::set.
|
static |
Advance the current generation of a set, adding exclusion ranges if necessary.
set | the set where we want to advance the generation |
Definition at line 1401 of file gnunet-service-set.c.
References Set::content, Set::current_generation, GenerationRange::end, Set::excluded_generations, Set::excluded_generations_size, GNUNET_array_append, GNUNET_assert, SetContent::latest_generation, and GenerationRange::start.
Referenced by handle_client_accept(), handle_client_copy_lazy_connect(), and handle_client_evaluate().
|
static |
Called when a client wants to initiate a set operation with another peer.
Initiates the CADET connection to the listener and sends the request.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1434 of file gnunet-service-set.c.
References GNUNET_OK.
|
static |
Called when a client wants to initiate a set operation with another peer.
Initiates the CADET connection to the listener and sends the request.
cls | client that sent the message |
msg | message sent by the client |
Definition at line 1451 of file gnunet-service-set.c.
References advance_generation(), cadet, channel_end_cb(), channel_window_cb(), ClientState::client, context, Set::current_generation, SetVT::evaluate, GNUNET_break, GNUNET_CADET_channel_create(), GNUNET_CADET_get_mq(), GNUNET_CONTAINER_DLL_insert, GNUNET_CRYPTO_QUALITY_NONCE, GNUNET_CRYPTO_random_u32(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_h2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_DONE, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENTS, GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DEMAND, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_DONE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_DONE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_FULL_ELEMENT, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_IBF, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_INQUIRY, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OFFER, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_OVER, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_REQUEST_FULL, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SEC, GNUNET_MQ_extract_nested_mh, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), msg, op, Set::operation, Set::ops_head, Set::ops_tail, ClientState::set, and Set::vt.
|
static |
Handle an ack from a client, and send the next element.
Note that we only expect acks for set elements, not after the GNUNET_MESSAGE_TYPE_SET_ITER_DONE message.
cls | client the client |
ack | the message |
Definition at line 1579 of file gnunet-service-set.c.
References ClientState::client, Set::cs, GNUNET_break, GNUNET_CONTAINER_multihashmap_iterator_destroy(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), Set::iter, Set::iteration_id, send_client_element(), GNUNET_SET_IterAckMessage::send_more, and ClientState::set.
|
static |
Handle a request from the client to copy a set.
cls | the client |
mh | the message |
Definition at line 1620 of file gnunet-service-set.c.
References ClientState::client, LazyCopyRequest::cookie, GNUNET_SET_CopyLazyResponseMessage::cookie, Set::cs, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_SET_COPY_LAZY_RESPONSE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), lazy_copy_cookie, lazy_copy_head, lazy_copy_tail, ClientState::mq, ClientState::set, and LazyCopyRequest::source_set.
|
static |
Handle a request from the client to connect to a copy of a set.
cls | the client |
msg | the message |
Definition at line 1656 of file gnunet-service-set.c.
References _GSS_intersection_vt(), _GSS_union_vt(), advance_generation(), ClientState::client, Set::content, LazyCopyRequest::cookie, SetVT::copy_state, Set::cs, Set::current_generation, Set::excluded_generations, Set::excluded_generations_size, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_log, GNUNET_memdup, GNUNET_new, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SET_OPERATION_INTERSECTION, GNUNET_SET_OPERATION_UNION, GNUNET_YES, lazy_copy_head, lazy_copy_tail, msg, LazyCopyRequest::next, Set::operation, SetContent::refcount, ClientState::set, LazyCopyRequest::source_set, Set::state, and Set::vt.
|
static |
Handle a request from the client to cancel a running set operation.
cls | the client |
msg | the message |
Definition at line 1747 of file gnunet-service-set.c.
References _GSS_operation_destroy(), ClientState::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, msg, GNUNET_ARM_Operation::next, op, Set::ops_head, ClientState::set, and Operation::set.
|
static |
Handle a request from the client to accept a set operation that came from a remote peer.
We forward the accept to the associated operation for handling
cls | the client |
msg | the message |
Definition at line 1800 of file gnunet-service-set.c.
References SetVT::accept, advance_generation(), ClientState::client, Listener::cs, Set::cs, Set::current_generation, get_incoming(), GNUNET_assert, GNUNET_break, GNUNET_CADET_receive_done(), GNUNET_CONTAINER_DLL_insert, GNUNET_CONTAINER_DLL_remove, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_MESSAGE_TYPE_SET_RESULT, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_SET_STATUS_FAILURE, ClientState::listener, ClientState::mq, msg, op, Listener::op_head, Listener::op_tail, Set::ops_head, Set::ops_tail, GNUNET_SET_ResultMessage::request_id, GNUNET_SET_ResultMessage::result_status, ClientState::set, and Set::vt.
|
static |
Called to clean up, after a shutdown has been requested.
cls | closure, NULL |
Definition at line 1875 of file gnunet-service-set.c.
References _GSS_statistics, cadet, GNUNET_CADET_disconnect(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_STATISTICS_destroy(), GNUNET_YES, in_shutdown, and num_clients.
Referenced by run().
|
static |
Function called by the service's run method to run service-specific setup code.
cls | closure |
cfg | configuration to use |
service | the initialized service |
Definition at line 1901 of file gnunet-service-set.c.
References _, _GSS_statistics, cadet, cfg, GNUNET_CADET_connect(), GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), and shutdown_task().
Define "main" method using service macro.
|
static |
Handle to the cadet service, used to listen for and connect to remote peers.
Definition at line 125 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), handle_client_evaluate(), handle_client_listen(), run(), and shutdown_task().
|
static |
DLL of lazy copy requests by this client.
Definition at line 130 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), handle_client_copy_lazy_connect(), and handle_client_copy_lazy_prepare().
|
static |
DLL of lazy copy requests by this client.
Definition at line 135 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), handle_client_copy_lazy_connect(), and handle_client_copy_lazy_prepare().
|
static |
Generator for unique cookie we set per lazy copy request.
Definition at line 140 of file gnunet-service-set.c.
Referenced by handle_client_copy_lazy_prepare().
struct GNUNET_STATISTICS_Handle* _GSS_statistics |
Statistics handle.
Definition at line 145 of file gnunet-service-set.c.
Referenced by decode_and_send(), fail_intersection_operation(), handle_union_p2p_demand(), handle_union_p2p_elements(), handle_union_p2p_full_element(), handle_union_p2p_strata_estimator(), run(), send_bloomfilter(), send_client_done(), send_client_done_and_destroy(), send_client_removed_element(), send_ibf(), shutdown_task(), union_accept(), and union_evaluate().
|
static |
Listeners are held in a doubly linked list.
Definition at line 150 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), get_incoming(), and handle_client_listen().
|
static |
Listeners are held in a doubly linked list.
Definition at line 155 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), and handle_client_listen().
|
static |
Number of active clients.
Definition at line 160 of file gnunet-service-set.c.
Referenced by client_connect_cb(), client_disconnect_cb(), and shutdown_task().
|
static |
Are we in shutdown? if GNUNET_YES and the number of clients drops to zero, disconnect from CADET.
Definition at line 166 of file gnunet-service-set.c.
Referenced by client_disconnect_cb(), and shutdown_task().
|
static |
Counter for allocating unique IDs for clients, used to identify incoming operation requests from remote peers, that the client can choose to accept or refuse.
0 must not be used (reserved for uninitialized).
Definition at line 174 of file gnunet-service-set.c.
Referenced by handle_incoming_msg().