GNUnet 0.22.2
gnunet-service-set.h File Reference

common components for the implementation the different set operations More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_protocols.h"
#include "gnunet_applications.h"
#include "gnunet_core_service.h"
#include "gnunet_cadet_service.h"
#include "gnunet_set_service.h"
#include "set.h"
Include dependency graph for gnunet-service-set.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SetVT
 Dispatch table for a specific set operation. More...
 
struct  MutationEvent
 MutationEvent gives information about changes to an element (removal / addition) in a set content. More...
 
struct  ElementEntry
 Information about an element element in the set. More...
 
struct  ClientState
 State we keep per client. More...
 
struct  Operation
 Operation context used to execute a set operation. More...
 
struct  SetContent
 SetContent stores the actual set elements, which may be shared by multiple generations derived from one set. More...
 
struct  GenerationRange
 
struct  PendingMutation
 Information about a mutation to apply to a set. More...
 
struct  Set
 A set that supports a specific operation with other peers. More...
 

Typedefs

typedef struct SetState *(* SetCreateImpl) (void)
 Signature of functions that create the implementation-specific state for a set supporting a specific operation. More...
 
typedef void(* SetAddRemoveImpl) (struct SetState *state, struct ElementEntry *ee)
 Signature of functions that implement the add/remove functionality for a set supporting a specific operation. More...
 
typedef struct SetState *(* SetCopyStateImpl) (struct SetState *state)
 Make a copy of a set's internal state. More...
 
typedef void(* SetDestroyImpl) (struct SetState *state)
 Signature of functions that implement the destruction of the implementation-specific set state. More...
 
typedef struct OperationState *(* OpAcceptImpl) (struct Operation *op)
 Signature of functions that implement accepting a set operation. More...
 
typedef struct OperationState *(* OpEvaluateImpl) (struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
 Signature of functions that implement starting the evaluation of set operations. More...
 
typedef void(* OpCancelImpl) (struct Operation *op)
 Signature of functions that implement operation cancellation. More...
 
typedef void(* OpChannelDeathImpl) (struct Operation *op)
 Signature of functions called when the CADET channel died. More...
 

Functions

void _GSS_operation_destroy (struct Operation *op, int gc)
 Destroy the given operation. 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...
 
const struct SetVT_GSS_union_vt (void)
 Get the table with implementing functions for set union. More...
 
const struct SetVT_GSS_intersection_vt (void)
 Get the table with implementing functions for set intersection. More...
 
int _GSS_is_element_of_operation (struct ElementEntry *ee, struct Operation *op)
 Is element ee part of the set used by op? More...
 

Variables

struct GNUNET_STATISTICS_Handle_GSS_statistics
 Statistics handle. More...
 

Detailed Description

common components for the implementation the different set operations

Author
Florian Dold
Christian Grothoff

Definition in file gnunet-service-set.h.

Typedef Documentation

◆ SetCreateImpl

typedef struct SetState *(* SetCreateImpl) (void)

Signature of functions that create the implementation-specific state for a set supporting a specific operation.

Returns
a set state specific to the supported operation, NULL on error

Definition at line 1 of file gnunet-service-set.h.

◆ SetAddRemoveImpl

typedef void(* SetAddRemoveImpl) (struct SetState *state, struct ElementEntry *ee)

Signature of functions that implement the add/remove functionality for a set supporting a specific operation.

Parameters
setimplementation-specific set state
eeelement message from the client

Definition at line 87 of file gnunet-service-set.h.

◆ SetCopyStateImpl

typedef struct SetState *(* SetCopyStateImpl) (struct SetState *state)

Make a copy of a set's internal state.

Parameters
stateset state to copy
Returns
copy of the internal state

Definition at line 87 of file gnunet-service-set.h.

◆ SetDestroyImpl

typedef void(* SetDestroyImpl) (struct SetState *state)

Signature of functions that implement the destruction of the implementation-specific set state.

Parameters
statethe set state, contains implementation-specific data

Definition at line 108 of file gnunet-service-set.h.

◆ OpAcceptImpl

typedef struct OperationState *(* OpAcceptImpl) (struct Operation *op)

Signature of functions that implement accepting a set operation.

Parameters
opoperation that is created by accepting the operation, should be initialized by the implementation
Returns
operation-specific state to keep in op

Definition at line 108 of file gnunet-service-set.h.

◆ OpEvaluateImpl

typedef struct OperationState *(* OpEvaluateImpl) (struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)

Signature of functions that implement starting the evaluation of set operations.

Parameters
opoperation that is created, should be initialized to begin the evaluation
opaque_contextmessage to be transmitted to the listener to convince it to accept, may be NULL
Returns
operation-specific state to keep in op

Definition at line 108 of file gnunet-service-set.h.

◆ OpCancelImpl

typedef void(* OpCancelImpl) (struct Operation *op)

Signature of functions that implement operation cancellation.

This includes notifying the client about the operation's final state.

Parameters
opoperation state

Definition at line 144 of file gnunet-service-set.h.

◆ OpChannelDeathImpl

typedef void(* OpChannelDeathImpl) (struct Operation *op)

Signature of functions called when the CADET channel died.

Parameters
opoperation state

Definition at line 153 of file gnunet-service-set.h.

Function Documentation

◆ _GSS_operation_destroy()

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.

Parameters
opoperation to destroy
gcGNUNET_YES to perform garbage collection on the set

Definition at line 421 of file gnunet-service-set.c.

422{
423 struct Set *set = op->set;
424 struct GNUNET_CADET_Channel *channel;
425
426 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Destroying operation %p\n", op);
427 GNUNET_assert (NULL == op->listener);
428 if (NULL != op->state)
429 {
430 set->vt->cancel (op);
431 op->state = NULL;
432 }
433 if (NULL != set)
434 {
436 op->set = NULL;
437 }
438 if (NULL != op->context_msg)
439 {
440 GNUNET_free (op->context_msg);
441 op->context_msg = NULL;
442 }
443 if (NULL != (channel = op->channel))
444 {
445 /* This will free op; called conditionally as this helper function
446 is also called from within the channel disconnect handler. */
447 op->channel = NULL;
449 }
450 if ((NULL != set) && (GNUNET_YES == gc))
452 /* We rely on the channel end handler to free 'op'. When 'op->channel' was NULL,
453 * there was a channel end handler that will free 'op' on the call stack. */
454}
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:143
static void collect_generation_garbage(struct Set *set)
Collect and destroy elements that are not needed anymore, because their lifetime (as determined by th...
void GNUNET_CADET_channel_destroy(struct GNUNET_CADET_Channel *channel)
Destroy an existing channel.
Definition: cadet_api.c:833
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
#define GNUNET_log(kind,...)
@ GNUNET_YES
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_DEBUG
#define GNUNET_free(ptr)
Wrapper around free.
Opaque handle to a channel.
Definition: cadet.h:116
OpCancelImpl cancel
Callback for canceling an operation.
A set that supports a specific operation with other peers.
struct Operation * ops_head
Evaluate operations are held in a linked list.
struct Operation * ops_tail
Evaluate operations are held in a linked list.
const struct SetVT * vt
Virtual table for this set.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _GSS_operation_destroy2()

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.

1153{
1154 struct GNUNET_CADET_Channel *channel;
1155
1156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel_end_cb called\n");
1157 if (NULL != (channel = op->channel))
1158 {
1159 /* This will free op; called conditionally as this helper function
1160 is also called from within the channel disconnect handler. */
1161 op->channel = NULL;
1163 }
1164 if (NULL != op->listener)
1165 {
1167 return;
1168 }
1169 if (NULL != op->set)
1170 op->set->vt->channel_death (op);
1171 else
1173 GNUNET_free (op);
1174}
static void incoming_destroy(struct Operation *op)
Destroy an incoming request from a remote peer.
void _GSS_operation_destroy(struct Operation *op, int gc)
Destroy the given operation.

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _GSS_union_vt()

const struct SetVT * _GSS_union_vt ( void  )

Get the table with implementing functions for set union.

Returns
the operation specific VTable

Definition at line 2448 of file gnunet-service-set_union.c.

2449{
2450 static const struct SetVT union_vt = {
2452 .add = &union_add,
2453 .remove = &union_remove,
2454 .destroy_set = &union_set_destroy,
2455 .evaluate = &union_evaluate,
2456 .accept = &union_accept,
2457 .cancel = &union_op_cancel,
2458 .copy_state = &union_copy_state,
2459 .channel_death = &union_channel_death
2460 };
2461
2462 return &union_vt;
2463}
static void union_set_destroy(struct SetState *set_state)
Destroy a set that supports the union operation.
static struct OperationState * union_accept(struct Operation *op)
Accept an union operation request from a remote peer.
static struct OperationState * union_evaluate(struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
Initiate operation to evaluate a set union with a remote peer.
static struct SetState * union_set_create(void)
Create a new set supporting the union operation.
static void union_remove(struct SetState *set_state, struct ElementEntry *ee)
Remove the element given in the element message from the set.
static struct SetState * union_copy_state(struct SetState *state)
Copy union-specific set state.
static void union_channel_death(struct Operation *op)
Handle case where channel went down for an operation.
static void union_add(struct SetState *set_state, struct ElementEntry *ee)
Add the element from the given element message to the set.
static void union_op_cancel(struct Operation *op)
Destroy the union operation.
Dispatch table for a specific set operation.
SetCreateImpl create
Callback for the set creation.

References SetVT::create, union_accept(), union_add(), union_channel_death(), union_copy_state(), union_evaluate(), union_op_cancel(), union_remove(), union_set_create(), and union_set_destroy().

Referenced by handle_client_copy_lazy_connect(), and handle_client_create_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _GSS_intersection_vt()

const struct SetVT * _GSS_intersection_vt ( void  )

Get the table with implementing functions for set intersection.

Returns
the operation specific VTable

Definition at line 1310 of file gnunet-service-set_intersection.c.

1311{
1312 static const struct SetVT intersection_vt = {
1314 .add = &intersection_add,
1315 .remove = &intersection_remove,
1316 .destroy_set = &intersection_set_destroy,
1317 .evaluate = &intersection_evaluate,
1318 .accept = &intersection_accept,
1319 .cancel = &intersection_op_cancel,
1320 .channel_death = &intersection_channel_death,
1321 };
1322
1323 return &intersection_vt;
1324}
static void intersection_remove(struct SetState *set_state, struct ElementEntry *element)
Remove the element given in the element message from the set.
static struct SetState * intersection_set_create()
Create a new set supporting the intersection operation.
static void intersection_set_destroy(struct SetState *set_state)
Destroy a set that supports the intersection operation.
static struct OperationState * intersection_evaluate(struct Operation *op, const struct GNUNET_MessageHeader *opaque_context)
Initiate a set intersection operation with a remote peer.
static void intersection_op_cancel(struct Operation *op)
Destroy the intersection operation.
static void intersection_add(struct SetState *set_state, struct ElementEntry *ee)
Add the element from the given element message to the set.
static void intersection_channel_death(struct Operation *op)
Callback for channel death for the intersection operation.
static struct OperationState * intersection_accept(struct Operation *op)
Accept an intersection operation request from a remote peer.

References SetVT::create, intersection_accept(), intersection_add(), intersection_channel_death(), intersection_evaluate(), intersection_op_cancel(), intersection_remove(), intersection_set_create(), and intersection_set_destroy().

Referenced by handle_client_copy_lazy_connect(), and handle_client_create_set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _GSS_is_element_of_operation()

int _GSS_is_element_of_operation ( struct ElementEntry ee,
struct Operation op 
)

Is element ee part of the set used by op?

Parameters
eeelement to test
opoperation the defines the set and its generation
Returns
GNUNET_YES if the element is in the set, GNUNET_NO if not

Definition at line 398 of file gnunet-service-set.c.

399{
400 return is_element_of_generation (ee,
401 op->generation_created,
402 op->set->excluded_generations,
403 op->set->excluded_generations_size);
404}
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?

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().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ _GSS_statistics