static struct Set *
set_get (struct GNUNET_SERVICE_Client *client)
{
- struct Set *set;
-
- for (set = sets_head; NULL != set; set = set->next)
+ for (struct Set *set = sets_head; NULL != set; set = set->next)
if (set->client == client)
return set;
return NULL;
static struct Listener *
listener_get (struct GNUNET_SERVICE_Client *client)
{
- struct Listener *listener;
-
- for (listener = listeners_head; NULL != listener; listener = listener->next)
+ for (struct Listener *listener = listeners_head;
+ NULL != listener;
+ listener = listener->next)
if (listener->client == client)
return listener;
return NULL;
static struct Operation *
get_incoming (uint32_t id)
{
- struct Operation *op;
-
- for (op = incoming_head; NULL != op; op = op->next)
+ for (struct Operation *op = incoming_head; NULL != op; op = op->next)
if (op->suggest_id == id)
{
GNUNET_assert (GNUNET_YES == op->is_incoming);
{
case GNUNET_SET_OPERATION_INTERSECTION:
set->vt = _GSS_intersection_vt ();
- set->type = OT_INTERSECTION;
break;
case GNUNET_SET_OPERATION_UNION:
set->vt = _GSS_union_vt ();
- set->type = OT_UNION;
break;
default:
GNUNET_free (set);
GNUNET_SERVICE_client_drop (client);
return;
}
- set->operation = ntohl (msg->operation);
+ set->operation = (enum GNUNET_SET_OperationType) ntohl (msg->operation);
set->state = set->vt->create ();
if (NULL == set->state)
{
incoming = get_incoming (ntohl (msg->accept_reject_id));
if (NULL == incoming)
{
- /* no matching incoming operation for this reject */
- GNUNET_break (0);
- GNUNET_SERVICE_client_drop (client);
+ /* no matching incoming operation for this reject;
+ could be that the other peer already disconnected... */
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Client rejected unknown operation %u\n",
+ (unsigned int) ntohl (msg->accept_reject_id));
+ GNUNET_SERVICE_client_continue (client);
return;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_SERVICE_client_drop (client);
return;
}
-
GNUNET_SERVICE_client_continue (client);
if (0 != set->content->iterator_count)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Scheduling mutation on set\n");
-
pm = GNUNET_new (struct PendingMutation);
pm->mutation_message = GNUNET_copy_message (m);
pm->set = set;
pm);
return;
}
- execute_mutation (set, m);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Executing mutation on set\n");
+ execute_mutation (set,
+ m);
}
if (set->current_generation == set->content->latest_generation)
{
- set->content->latest_generation += 1;
- set->current_generation += 1;
+ set->content->latest_generation++;
+ set->current_generation++;
return;
}
r.start = set->current_generation + 1;
r.end = set->content->latest_generation + 1;
-
set->content->latest_generation = r.end;
set->current_generation = r.end;
-
GNUNET_array_append (set->excluded_generations,
set->excluded_generations_size,
r);
// mutations won't interfer with the running operation.
op->generation_created = set->current_generation;
advance_generation (set);
- op->type = set->type;
+ op->operation = set->operation;
op->vt = set->vt;
GNUNET_CONTAINER_DLL_insert (set->ops_head,
set->ops_tail,
{
case GNUNET_SET_OPERATION_INTERSECTION:
set->vt = _GSS_intersection_vt ();
- set->type = OT_INTERSECTION;
break;
case GNUNET_SET_OPERATION_UNION:
set->vt = _GSS_union_vt ();
- set->type = OT_UNION;
break;
default:
GNUNET_assert (0);
advance_generation (set);
op->vt = set->vt;
- op->type = set->type;
+ op->operation = set->operation;
op->vt->accept (op);
GNUNET_SERVICE_client_continue (client);
}
struct Listener;
-/**
- * Possible set operations.
- */
-enum OperationType {
- /**
- * Operation type unknown.
- */
- OT_UNKNOWN = 0,
-
- /**
- * We are performing a union.
- */
- OT_UNION,
-
- /**
- * We are performing an intersection.
- */
- OT_INTERSECTION
-};
-
-
/**
* Operation context used to execute a set operation.
*/
struct GNUNET_SCHEDULER_Task *timeout_task;
/**
- * What type of operation is this?
+ * The type of the operation.
*/
- enum OperationType type;
+ enum GNUNET_SET_OperationType operation;
/**
* Unique request id for the request from a remote peer, sent to the
*/
struct Operation *ops_tail;
- /**
- * What type of operation is this set for?
- */
- enum OperationType type;
-
/**
* Current generation, that is, number of previously executed
* operations and lazy copies on the underlying set content.
struct Operation *op = cls;
unsigned int buckets_in_message;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
{
struct Operation *op = cls;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
{
struct Operation *op = cls;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
struct Operation *op = cls;
unsigned int num_keys;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
LOG (GNUNET_ERROR_TYPE_INFO,
"Received request for full set transmission\n");
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
fail_union_operation (op);
struct Operation *op = cls;
unsigned int num_hashes;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
struct Operation *op = cls;
unsigned int num_hashes;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
return GNUNET_SYSERR;
{
struct Operation *op = cls;
- if (OT_UNION != op->type)
+ if (GNUNET_SET_OPERATION_UNION != op->operation)
{
GNUNET_break_op (0);
fail_union_operation (op);