new timeout tests for WLAN and bluetooth
[oweals/gnunet.git] / src / set / gnunet-service-set.c
index d4c347d48063c6bd5a523a4cd75f3ea930aa8297..9cc2e56f6b280cadb0fae091317638eeb9322df5 100644 (file)
@@ -199,9 +199,13 @@ get_incoming (uint32_t id)
 {
   struct Operation *op;
 
-  for (op = incoming_head; NULL != op; op = op)
+  for (op = incoming_head; NULL != op; op = op->next)
     if (op->state->suggest_id == id)
+    {
+      // FIXME: remove this assertion once the corresponding bug is gone!
+      GNUNET_assert (GNUNET_YES == op->is_incoming);
       return op;
+    }
   return NULL;
 }
 
@@ -237,7 +241,7 @@ listener_destroy (struct Listener *listener)
  * 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.
- * 
+ *
  * We hereby replace the old element hashmap with a new one, instead of removing elements.
  */
 void
@@ -252,7 +256,7 @@ collect_generation_garbage (struct Set *set)
   new_elements = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
   iter = GNUNET_CONTAINER_multihashmap_iterator_create (set->elements);
   while (GNUNET_OK ==
-         (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee))) 
+         (res = GNUNET_CONTAINER_multihashmap_iterator_next (iter, NULL, (const void **) &ee)))
   {
     if (GNUNET_NO == ee->removed)
       goto still_needed;
@@ -284,6 +288,7 @@ void
 _GSS_operation_destroy (struct Operation *op)
 {
   struct Set *set;
+  struct GNUNET_MESH_Channel *channel;
 
   if (NULL == op->vt)
     return;
@@ -316,10 +321,10 @@ _GSS_operation_destroy (struct Operation *op)
     op->mq = NULL;
   }
 
-  if (NULL != op->channel)
+  if (NULL != (channel = op->channel))
   {
-    GNUNET_MESH_channel_destroy (op->channel);
     op->channel = NULL;
+    GNUNET_MESH_channel_destroy (channel);
   }
 
   collect_generation_garbage (set);
@@ -335,10 +340,10 @@ _GSS_operation_destroy (struct Operation *op)
  *
  * @param cls closure
  * @param key current key code
- * @param value value in the hash map
- * @return GNUNET_YES if we should continue to
+ * @param value a `struct ElementEntry *` to be free'd
+ * @return #GNUNET_YES if we should continue to
  *         iterate,
- *         GNUNET_NO if not.
+ *         #GNUNET_NO if not.
  */
 static int
 destroy_elements_iterator (void *cls,
@@ -411,21 +416,23 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
   struct Set *set;
   struct Listener *listener;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client disconnected, cleaning up\n");
-
+  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");
+    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");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "(client's listener destroyed)\n");
   }
 }
 
@@ -438,25 +445,33 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client)
 static void
 incoming_destroy (struct Operation *incoming)
 {
+  GNUNET_assert (GNUNET_YES == incoming->is_incoming);
   GNUNET_CONTAINER_DLL_remove (incoming_head, incoming_tail, incoming);
   if (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task)
   {
     GNUNET_SCHEDULER_cancel (incoming->state->timeout_task);
     incoming->state->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   }
+  GNUNET_assert (NULL != incoming->state);
   GNUNET_free (incoming->state);
+  // make sure that the tunnel end handler will not
+  // destroy us again
+  incoming->vt = NULL;
+  incoming->state = NULL;
 }
 
+
 /**
  * remove & free state of the operation from the incoming list
- * 
+ *
  * @param incoming the element to remove
  */
-
 static void
 incoming_retire (struct Operation *incoming)
 {
+  GNUNET_assert (GNUNET_YES == incoming->is_incoming);
   incoming->is_incoming = GNUNET_NO;
+  GNUNET_assert (NULL != incoming->state);
   GNUNET_free (incoming->state);
   incoming->state = NULL;
   GNUNET_CONTAINER_DLL_remove (incoming_head, incoming_tail, incoming);
@@ -502,7 +517,9 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
 {
   struct GNUNET_MQ_Envelope *mqm;
   struct GNUNET_SET_RequestMessage *cmsg;
-
+  
+  GNUNET_assert (GNUNET_YES == incoming->is_incoming);
+  GNUNET_assert (NULL != incoming->state);
   GNUNET_assert (NULL != incoming->spec);
   GNUNET_assert (0 == incoming->state->suggest_id);
   incoming->state->suggest_id = suggest_id++;
@@ -510,7 +527,7 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
   GNUNET_assert (GNUNET_SCHEDULER_NO_TASK != incoming->state->timeout_task);
   GNUNET_SCHEDULER_cancel (incoming->state->timeout_task);
   incoming->state->timeout_task = GNUNET_SCHEDULER_NO_TASK;
-  
+
   mqm = GNUNET_MQ_msg_nested_mh (cmsg, GNUNET_MESSAGE_TYPE_SET_REQUEST,
                                  incoming->spec->context_msg);
   GNUNET_assert (NULL != mqm);
@@ -524,16 +541,16 @@ incoming_suggest (struct Operation *incoming, struct Listener *listener)
 
 /**
  * Handle a request for a set operation from
- * another peer. 
- * 
- * This msg is expected as the first and only msg handled through the 
+ * another peer.
+ *
+ * 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.
  *
  * @param op the operation state
  * @param mh the received message
- * @return GNUNET_OK if the channel should be kept alive,
- *         GNUNET_SYSERR to destroy the channel
+ * @return #GNUNET_OK if the channel should be kept alive,
+ *         #GNUNET_SYSERR to destroy the channel
  */
 static int
 handle_incoming_msg (struct Operation *op,
@@ -543,6 +560,8 @@ handle_incoming_msg (struct Operation *op,
   struct Listener *listener;
   struct OperationSpecification *spec;
 
+  GNUNET_assert (GNUNET_YES == op->is_incoming);
+
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "got op request\n");
 
   if (GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST != ntohs (mh->type))
@@ -567,6 +586,7 @@ handle_incoming_msg (struct Operation *op,
   spec->app_id = msg->app_id;
   spec->salt = ntohl (msg->salt);
   spec->peer = op->state->peer;
+  spec->remote_element_count = ntohl (msg->element_count);
 
   op->spec = spec;
 
@@ -677,14 +697,16 @@ handle_client_create_set (void *cls,
                           struct GNUNET_SERVER_Client *client,
                           const struct GNUNET_MessageHeader *m)
 {
-  struct GNUNET_SET_CreateMessage *msg = (struct GNUNET_SET_CreateMessage *) m;
+  const struct GNUNET_SET_CreateMessage *msg;
   struct Set *set;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client created new set (operation %u)\n",
+  msg = (const struct GNUNET_SET_CreateMessage *) m;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "client created new set (operation %u)\n",
               ntohs (msg->operation));
 
   // max. one set per client!
-  if (NULL != set_get (client)) 
+  if (NULL != set_get (client))
   {
     GNUNET_break (0);
     GNUNET_SERVER_client_disconnect (client);
@@ -730,37 +752,44 @@ handle_client_listen (void *cls,
                       struct GNUNET_SERVER_Client *client,
                       const struct GNUNET_MessageHeader *m)
 {
-  struct GNUNET_SET_ListenMessage *msg = (struct GNUNET_SET_ListenMessage *) m;
+  const struct GNUNET_SET_ListenMessage *msg;
   struct Listener *listener;
   struct Operation *op;
 
-  // max. one per client!
+  msg = (const struct GNUNET_SET_ListenMessage *) m;
+  /* max. one per client! */
   if (NULL != listener_get (client))
   {
     GNUNET_break (0);
     GNUNET_SERVER_client_disconnect (client);
     return;
   }
-  
+
   listener = GNUNET_new (struct Listener);
   listener->client = client;
   listener->client_mq = GNUNET_MQ_queue_for_server_client (client);
   listener->app_id = msg->app_id;
   listener->operation = ntohl (msg->operation);
   GNUNET_CONTAINER_DLL_insert_tail (listeners_head, listeners_tail, listener);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new listener created (op %u, app %s)\n",
-              listener->operation, GNUNET_h2s (&listener->app_id));
-  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "new listener created (op %u, app %s)\n",
+              listener->operation,
+              GNUNET_h2s (&listener->app_id));
+
   /* check for incoming requests the listener is interested in */
   for (op = incoming_head; NULL != op; op = op->next)
   {
     if (NULL == op->spec)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "request has no spec yet\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "request has no spec yet\n");
       continue;
     }
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "considering (op: %u, app: %s, suggest: %u)\n",
-                op->spec->operation, GNUNET_h2s (&op->spec->app_id), op->state->suggest_id);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "considering (op: %u, app: %s, suggest: %u)\n",
+                op->spec->operation,
+                GNUNET_h2s (&op->spec->app_id),
+                op->state->suggest_id);
 
     /* don't consider the incoming request if it has been already suggested to a listener */
     if (0 != op->state->suggest_id)
@@ -769,10 +798,12 @@ handle_client_listen (void *cls,
       continue;
     if (0 != GNUNET_CRYPTO_hash_cmp (&listener->app_id, &op->spec->app_id))
       continue;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "request suggested\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "request suggested\n");
     incoming_suggest (op, listener);
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "considered all incoming requests\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "considered all incoming requests\n");
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
 }
 
@@ -803,8 +834,9 @@ handle_client_reject (void *cls,
     GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
     return;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "peer request rejected by client\n");
-  
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "peer request rejected by client\n");
+
   GNUNET_MESH_channel_destroy (incoming->channel);
   //channel destruction handler called immediately upon destruction
   GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -851,12 +883,14 @@ handle_client_add_remove (void *cls,
     ee = GNUNET_CONTAINER_multihashmap_get (set->elements, &hash);
     if (NULL == ee)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "client tried to remove non-existing element\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "client tried to remove non-existing element\n");
       return;
     }
     if (GNUNET_YES == ee->removed)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "client tried to remove element twice\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                  "client tried to remove element twice\n");
       return;
     }
     ee->removed = GNUNET_YES;
@@ -878,7 +912,8 @@ handle_client_add_remove (void *cls,
                                                 &ee->element_hash);
     if (NULL != ee_dup)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "element inserted twice, ignoring\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                  "element inserted twice, ignoring\n");
       GNUNET_free (ee);
       return;
     }
@@ -902,7 +937,7 @@ handle_client_evaluate (void *cls,
                         const struct GNUNET_MessageHeader *m)
 {
   struct Set *set;
-  struct GNUNET_SET_EvaluateMessage *msg;
+  const struct GNUNET_SET_EvaluateMessage *msg;
   struct OperationSpecification *spec;
   struct Operation *op;
 
@@ -914,7 +949,7 @@ handle_client_evaluate (void *cls,
     return;
   }
 
-  msg = (struct GNUNET_SET_EvaluateMessage *) m;
+  msg = (const struct GNUNET_SET_EvaluateMessage *) m;
   spec = GNUNET_new (struct OperationSpecification);
   spec->operation = set->operation;
   spec->app_id = msg->app_id;
@@ -924,7 +959,7 @@ handle_client_evaluate (void *cls,
   spec->result_mode = ntohs (msg->result_mode);
   spec->client_request_id = ntohl (msg->request_id);
   spec->context_msg = GNUNET_MQ_extract_nested_mh (msg);
-  
+
   // for simplicity we just backup the context msg instead of rebuilding it later on
   if (NULL != spec->context_msg)
     spec->context_msg = GNUNET_copy_message (spec->context_msg);
@@ -936,9 +971,8 @@ handle_client_evaluate (void *cls,
   GNUNET_CONTAINER_DLL_insert (set->ops_head, set->ops_tail, op);
 
   op->channel = GNUNET_MESH_channel_create (mesh, op, &msg->target_peer,
-                                          GNUNET_APPLICATION_TYPE_SET,
-                                          GNUNET_YES,
-                                          GNUNET_YES);
+                                            GNUNET_APPLICATION_TYPE_SET,
+                                            GNUNET_MESH_OPTION_RELIABLE);
 
   op->mq = GNUNET_MESH_mq_create (op->channel);
 
@@ -949,7 +983,7 @@ handle_client_evaluate (void *cls,
 
 /**
  * Handle an ack from a client, and send the next element.
- * 
+ *
  * @param cls unused
  * @param client the client
  * @param m the message
@@ -1026,7 +1060,7 @@ handle_client_cancel (void *cls,
     GNUNET_SERVER_client_disconnect (client);
     return;
   }
-  
+
   _GSS_operation_destroy (op);
 }
 
@@ -1035,7 +1069,7 @@ handle_client_cancel (void *cls,
  * 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
- * 
+ *
  * @param cls unused
  * @param client the client
  * @param mh the message
@@ -1046,9 +1080,10 @@ handle_client_accept (void *cls,
                       const struct GNUNET_MessageHeader *mh)
 {
   struct Set *set;
-  struct GNUNET_SET_AcceptRejectMessage *msg = (struct GNUNET_SET_AcceptRejectMessage *) mh;
+  const struct GNUNET_SET_AcceptRejectMessage *msg;
   struct Operation *op;
 
+  msg = (const struct GNUNET_SET_AcceptRejectMessage *) mh;
   op = get_incoming (ntohl (msg->accept_reject_id));
 
   // incoming operation does not exist
@@ -1059,13 +1094,15 @@ handle_client_accept (void *cls,
     return;
   }
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client accepting %u\n", ntohl (msg->accept_reject_id));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "client accepting %u\n",
+              ntohl (msg->accept_reject_id));
 
   GNUNET_assert (GNUNET_YES == op->is_incoming);
 
   // client without a set requested an operation
   set = set_get (client);
-  
+
   if (NULL == set)
   {
     GNUNET_break (0);
@@ -1118,17 +1155,18 @@ shutdown_task (void *cls,
     GNUNET_MESH_disconnect (mesh);
     mesh = NULL;
   }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled shutdown request\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "handled shutdown request\n");
 }
 
 
 /**
  * Timeout happens iff:
- *  - we suggested an operation to our listener, 
+ *  - we suggested an operation to our listener,
  *    but did not receive a response in time
- *  - we got the channel from a peer but no GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
+ *  - we got the channel from a peer but no #GNUNET_MESSAGE_TYPE_SET_P2P_OPERATION_REQUEST
  *  - shutdown (obviously)
+ *
  * @param cls channel context
  * @param tc context information (why was this task triggered now)
  */
@@ -1138,12 +1176,12 @@ incoming_timeout_cb (void *cls,
 {
   struct Operation *incoming = cls;
 
+  incoming->state->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   GNUNET_assert (GNUNET_YES == incoming->is_incoming);
-
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "remote peer timed out\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "remote peer timed out\n");
   incoming_destroy (incoming);
 }
 
@@ -1151,18 +1189,15 @@ incoming_timeout_cb (void *cls,
 /**
  * Terminates an incoming operation in case we have not yet received an
  * operation request. Called by the channel destruction handler.
- * 
+ *
  * @param op the channel context
  */
 static void
 handle_incoming_disconnect (struct Operation *op)
 {
   GNUNET_assert (GNUNET_YES == op->is_incoming);
-  
-  if (NULL == op->channel)
-    return;
-
   incoming_destroy (op);
+  op->vt = NULL;
 }
 
 
@@ -1170,16 +1205,17 @@ handle_incoming_disconnect (struct Operation *op)
  * Method called whenever another peer has added us to a channel
  * the other peer initiated.
  * Only called (once) upon reception of data with a message type which was
- * subscribed to in GNUNET_MESH_connect
- * 
+ * subscribed to in GNUNET_MESH_connect().
+ *
  * 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 
+ * from where it gets looked up when our local listener client responds
  * to a proposed/suggested operation or connects and associates with this operation.
  *
  * @param cls closure
  * @param channel new handle to the channel
  * @param initiator peer that started the channel
  * @param port Port this channel is for.
+ * @param options Unused.
  * @return initial channel context for the channel
  *         (can be NULL -- that's not an error)
  */
@@ -1187,7 +1223,7 @@ static void *
 channel_new_cb (void *cls,
                struct GNUNET_MESH_Channel *channel,
                const struct GNUNET_PeerIdentity *initiator,
-               uint32_t port)
+               uint32_t port, enum GNUNET_MESH_ChannelOption options)
 {
   struct Operation *incoming;
   static const struct SetVT incoming_vt = {
@@ -1195,9 +1231,16 @@ channel_new_cb (void *cls,
     .peer_disconnect = handle_incoming_disconnect
   };
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "new incoming channel\n");
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "new incoming channel\n");
+
+  if (GNUNET_APPLICATION_TYPE_SET != port)
+  {
+    GNUNET_break (0);
+    GNUNET_MESH_channel_destroy (channel);
+    return NULL;
+  }
 
-  GNUNET_assert (port == GNUNET_APPLICATION_TYPE_SET);
   incoming = GNUNET_new (struct Operation);
   incoming->is_incoming = GNUNET_YES;
   incoming->state = GNUNET_new (struct OperationState);
@@ -1206,7 +1249,8 @@ channel_new_cb (void *cls,
   incoming->mq = GNUNET_MESH_mq_create (incoming->channel);
   incoming->vt = &incoming_vt;
   incoming->state->timeout_task =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, incoming_timeout_cb, incoming);
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+                                    &incoming_timeout_cb, incoming);
   GNUNET_CONTAINER_DLL_insert_tail (incoming_head, incoming_tail, incoming);
 
   return incoming;
@@ -1215,57 +1259,65 @@ channel_new_cb (void *cls,
 
 /**
  * Function called whenever a channel is destroyed.  Should clean up
- * any associated state.
- * GNUNET_MESH_channel_destroy. It must NOT call GNUNET_MESH_channel_destroy on
- * the channel.
- * 
- * The peer_disconnect function is part of a a virtual table set initially either 
+ * any associated state.  It must NOT call
+ * GNUNET_MESH_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 (channel_new_cb), or once we create
- * a new channel ourselves (evaluate). 
- * 
- * Once we know the exact type of operation (union/intersection), the vt is 
+ * 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).
  *
- * @param cls closure (set from GNUNET_MESH_connect)
+ * @param cls closure (set from GNUNET_MESH_connect())
  * @param channel connection to the other end (henceforth invalid)
  * @param channel_ctx place where local state associated
  *                   with the channel is stored
  */
 static void
 channel_end_cb (void *cls,
-               const struct GNUNET_MESH_Channel *channel, void *channel_ctx)
+                const struct GNUNET_MESH_Channel *channel, void *channel_ctx)
 {
   struct Operation *op = channel_ctx;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "channel end cb called\n");
-
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "channel end cb called\n");
   op->channel = NULL;
-
+  /* the vt can be null if a client already requested canceling op. */
   if (NULL != op->vt)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "calling peer disconnect due to channel end\n");
     op->vt->peer_disconnect (op);
+  }
+
+  if (GNUNET_YES == op->keep)
+    return;
+
   /* mesh will never call us with the context again! */
   GNUNET_free (channel_ctx);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "channel end cb finished\n");
 }
 
 
 /**
- * Functions with this signature are called whenever any message is
- * received via the mesh channel.
+ * Functions with this signature are called whenever a message is
+ * received via a mesh channel.
  *
- * The msg_handler is a virtual table set in initially either when a peer 
- * creates a new channel with us (channel_new_cb), or once we create a new channel 
- * ourselves (evaluate). 
- * 
- * Once we know the exact type of operation (union/intersection), the vt is 
+ * The msg_handler is a virtual table set in initially either when a peer
+ * creates a new channel with us (channel_new_cb), 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).
  *
- * @param cls Closure (set from GNUNET_MESH_connect).
+ * @param cls Closure (set from GNUNET_MESH_connect()).
  * @param channel Connection to the other end.
  * @param channel_ctx Place to store local state associated with the channel.
  * @param message The actual message.
- *
- * @return GNUNET_OK to keep the channel open,
- *         GNUNET_SYSERR to close it (signal serious error).
+ * @return #GNUNET_OK to keep the channel open,
+ *         #GNUNET_SYSERR to close it (signal serious error).
  */
 static int
 dispatch_p2p_message (void *cls,
@@ -1276,12 +1328,14 @@ dispatch_p2p_message (void *cls,
   struct Operation *op = *channel_ctx;
   int ret;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "dispatching mesh message (type: %u)\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "dispatching mesh message (type: %u)\n",
               ntohs (message->type));
   /* do this before the handler, as the handler might kill the channel */
   GNUNET_MESH_receive_done (channel);
   ret = op->vt->msg_handler (op, message);
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "handled mesh message (type: %u)\n",
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "handled mesh message (type: %u)\n",
               ntohs (message->type));
   return ret;
 }
@@ -1325,7 +1379,9 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
     {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_P2P_DONE, 0},
     {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_P2P_ELEMENT_REQUESTS, 0},
     {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_UNION_P2P_SE, 0},
+    {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_ELEMENT_INFO, 0},
     {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF, 0},
+    {dispatch_p2p_message, GNUNET_MESSAGE_TYPE_SET_INTERSECTION_P2P_BF_PART, 0},
     {NULL, 0, 0}
   };
   static const uint32_t mesh_ports[] = {GNUNET_APPLICATION_TYPE_SET, 0};
@@ -1340,11 +1396,10 @@ run (void *cls, struct GNUNET_SERVER_Handle *server,
                               mesh_handlers, mesh_ports);
   if (NULL == mesh)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not connect to mesh\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                _("Could not connect to mesh service\n"));
     return;
   }
-
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "started\n");
 }
 
 
@@ -1359,9 +1414,11 @@ int
 main (int argc, char *const *argv)
 {
   int ret;
+
   ret = GNUNET_SERVICE_run (argc, argv, "set",
                             GNUNET_SERVICE_OPTION_NONE, &run, NULL);
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, "exit (%d)\n", GNUNET_OK != ret);
   return (GNUNET_OK == ret) ? 0 : 1;
 }
 
+/* end of gnunet-service-set.c */
+