gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated (8ed6d6426 -> 47fdc2be7)


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated (8ed6d6426 -> 47fdc2be7)
Date: Tue, 24 Jan 2017 21:59:34 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository gnunet.

    from 8ed6d6426 fix client-client loopback flow control
     new 33fccc1e9 simplify logic
     new 2a4ba82b8 bitch and continue if we do not have a handler for a message
     new 5db97de36 nicer function names
     new 596a7b4d5 fix bug from compiler inserting padding if we try to 
allocate data at the end of the struct instead of in a new area
     new 47fdc2be7 use proper message type constants

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/cadet/cadet_api.c                        | 56 +++++++++++++---------------
 src/cadet/gnunet-service-cadet-new.c         | 16 ++++----
 src/cadet/gnunet-service-cadet-new_channel.c | 27 ++++++++------
 src/cadet/test_cadet.c                       |  9 +++--
 4 files changed, 55 insertions(+), 53 deletions(-)

diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 89d9daeda..72b7b692d 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -489,7 +489,9 @@ static void
 add_to_queue (struct GNUNET_CADET_Handle *h,
               struct GNUNET_CADET_TransmitHandle *th)
 {
-  GNUNET_CONTAINER_DLL_insert_tail (h->th_head, h->th_tail, th);
+  GNUNET_CONTAINER_DLL_insert_tail (h->th_head,
+                                    h->th_tail,
+                                    th);
 }
 
 
@@ -513,29 +515,6 @@ remove_from_queue (struct GNUNET_CADET_TransmitHandle *th)
 }
 
 
-/**
- * Send an ack on the channel to confirm the processing of a message.
- *
- * @param ch Channel on which to send the ACK.
- */
-static void
-send_ack (struct GNUNET_CADET_Channel *ch)
-{
-  struct GNUNET_CADET_LocalAck *msg;
-  struct GNUNET_MQ_Envelope *env;
-
-  env = GNUNET_MQ_msg (msg,
-                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
-
-  LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Sending ACK on channel %X\n",
-       ch->ccn.channel_of_client);
-  msg->ccn = ch->ccn;
-  GNUNET_MQ_send (ch->cadet->mq,
-                  env);
-}
-
-
 
 
/******************************************************************************/
 /***********************      RECEIVE HANDLERS     
****************************/
@@ -577,6 +556,7 @@ request_data (void *cls)
                       th->size,
                       &msg[1]);
   GNUNET_assert (osize == th->size);
+
   GNUNET_MQ_send (th->channel->cadet->mq,
                   env);
   GNUNET_free (th);
@@ -729,7 +709,6 @@ handle_local_data (void *cls,
   const struct GNUNET_MessageHeader *payload;
   const struct GNUNET_CADET_MessageHandler *handler;
   struct GNUNET_CADET_Channel *ch;
-  unsigned int i;
   uint16_t type;
 
   ch = retrieve_channel (h,
@@ -746,8 +725,7 @@ handle_local_data (void *cls,
        ntohl (message->ccn.channel_of_client),
        GC_m2s (type),
        type);
-
-  for (i = 0; i < h->n_handlers; i++)
+  for (unsigned i=0;i<h->n_handlers;i++)
   {
     handler = &h->message_handlers[i];
     if (handler->type == type)
@@ -761,11 +739,14 @@ handle_local_data (void *cls,
         LOG (GNUNET_ERROR_TYPE_DEBUG,
              "callback caused disconnection\n");
         GNUNET_CADET_channel_destroy (ch);
-        break;
+        return;
       }
-      break;
+      return;
     }
   }
+  /* Other peer sent message we do not comprehend. */
+  GNUNET_break_op (0);
+  GNUNET_CADET_receive_done (ch);
 }
 
 
@@ -1749,10 +1730,25 @@ GNUNET_CADET_notify_transmit_ready_cancel (struct 
GNUNET_CADET_TransmitHandle *t
 }
 
 
+/**
+ * Send an ack on the channel to confirm the processing of a message.
+ *
+ * @param ch Channel on which to send the ACK.
+ */
 void
 GNUNET_CADET_receive_done (struct GNUNET_CADET_Channel *channel)
 {
-  send_ack (channel);
+  struct GNUNET_CADET_LocalAck *msg;
+  struct GNUNET_MQ_Envelope *env;
+
+  env = GNUNET_MQ_msg (msg,
+                       GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Sending ACK on channel %X\n",
+       channel->ccn.channel_of_client);
+  msg->ccn = channel->ccn;
+  GNUNET_MQ_send (channel->cadet->mq,
+                  env);
 }
 
 
diff --git a/src/cadet/gnunet-service-cadet-new.c 
b/src/cadet/gnunet-service-cadet-new.c
index 097f77647..97489f3fd 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -635,8 +635,8 @@ handle_channel_destroy (void *cls,
  * @return #GNUNET_OK if @a msg is OK, #GNUNET_SYSERR if not
  */
 static int
-check_data (void *cls,
-            const struct GNUNET_CADET_LocalData *msg)
+check_local_data (void *cls,
+                  const struct GNUNET_CADET_LocalData *msg)
 {
   size_t payload_size;
   size_t payload_claimed_size;
@@ -691,8 +691,8 @@ check_data (void *cls,
  * @param msg the actual message
  */
 static void
-handle_data (void *cls,
-             const struct GNUNET_CADET_LocalData *msg)
+handle_local_data (void *cls,
+                   const struct GNUNET_CADET_LocalData *msg)
 {
   struct CadetClient *c = cls;
   struct CadetChannel *ch;
@@ -735,8 +735,8 @@ handle_data (void *cls,
  * @param msg The actual message.
  */
 static void
-handle_ack (void *cls,
-            const struct GNUNET_CADET_LocalAck *msg)
+handle_local_ack (void *cls,
+                  const struct GNUNET_CADET_LocalAck *msg)
 {
   struct CadetClient *c = cls;
   struct CadetChannel *ch;
@@ -1395,11 +1395,11 @@ GNUNET_SERVICE_MAIN
                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_DESTROY,
                           struct GNUNET_CADET_LocalChannelDestroyMessage,
                           NULL),
- GNUNET_MQ_hd_var_size (data,
+ GNUNET_MQ_hd_var_size (local_data,
                         GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA,
                         struct GNUNET_CADET_LocalData,
                         NULL),
- GNUNET_MQ_hd_fixed_size (ack,
+ GNUNET_MQ_hd_fixed_size (local_ack,
                           GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK,
                           struct GNUNET_CADET_LocalAck,
                           NULL),
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c 
b/src/cadet/gnunet-service-cadet-new_channel.c
index 98cfa8383..b97b2b577 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.c
+++ b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -126,9 +126,8 @@ struct CadetReliableMessage
   /**
    * Data message we are trying to send.
    */
-  struct GNUNET_CADET_ChannelAppDataMessage data_message;
+  struct GNUNET_CADET_ChannelAppDataMessage *data_message;
 
-  /* followed by variable-size payload */
 };
 
 
@@ -420,6 +419,7 @@ channel_destroy (struct CadetChannel *ch)
     GNUNET_CONTAINER_DLL_remove (ch->head_sent,
                                  ch->tail_sent,
                                  crm);
+    GNUNET_free (crm->data_message);
     GNUNET_free (crm);
   }
   if (NULL != ch->owner)
@@ -1188,7 +1188,7 @@ GCCH_handle_channel_plaintext_data_ack (struct 
CadetChannel *ch,
   for (crm = ch->head_sent;
         NULL != crm;
        crm = crm->next)
-    if (ack->mid.mid == crm->data_message.mid.mid)
+    if (ack->mid.mid == crm->data_message->mid.mid)
       break;
   if (NULL == crm)
   {
@@ -1206,12 +1206,13 @@ GCCH_handle_channel_plaintext_data_ack (struct 
CadetChannel *ch,
   GNUNET_CONTAINER_DLL_remove (ch->head_sent,
                                ch->tail_sent,
                                crm);
+  GNUNET_free (crm->data_message);
+  GNUNET_free (crm);
   ch->pending_messages--;
   send_ack_to_client (ch,
                       (NULL == ch->owner)
                       ? GNUNET_NO
                       : GNUNET_YES);
-  GNUNET_free (crm);
   GNUNET_assert (ch->pending_messages < ch->max_pending_messages);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Received DATA_ACK on %s for message %u (%u ACKs pending)\n",
@@ -1290,7 +1291,7 @@ retry_transmission (void *cls)
   ch->retry_data_task = NULL;
   GNUNET_assert (NULL == crm->qe);
   crm->qe = GCT_send (ch->t,
-                      &crm->data_message.header,
+                      &crm->data_message->header,
                       &data_sent_cb,
                       crm);
 }
@@ -1432,14 +1433,16 @@ GCCH_handle_local_data (struct CadetChannel *ch,
   }
 
   /* Everything is correct, send the message. */
-  crm = GNUNET_malloc (sizeof (*crm) + buf_len);
+  crm = GNUNET_malloc (sizeof (*crm));
   crm->ch = ch;
-  crm->data_message.header.size = htons (sizeof (struct 
GNUNET_CADET_ChannelAppDataMessage) + buf_len);
-  crm->data_message.header.type = htons 
(GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
+  crm->data_message = GNUNET_malloc (sizeof (struct 
GNUNET_CADET_ChannelAppDataMessage)
+                                     + buf_len);
+  crm->data_message->header.size = htons (sizeof (struct 
GNUNET_CADET_ChannelAppDataMessage) + buf_len);
+  crm->data_message->header.type = htons 
(GNUNET_MESSAGE_TYPE_CADET_CHANNEL_APP_DATA);
   ch->mid_send.mid = htonl (ntohl (ch->mid_send.mid) + 1);
-  crm->data_message.mid = ch->mid_send;
-  crm->data_message.ctn = ch->ctn;
-  GNUNET_memcpy (&crm[1],
+  crm->data_message->mid = ch->mid_send;
+  crm->data_message->ctn = ch->ctn;
+  GNUNET_memcpy (&crm->data_message[1],
                  buf,
                  buf_len);
   GNUNET_CONTAINER_DLL_insert (ch->head_sent,
@@ -1450,7 +1453,7 @@ GCCH_handle_local_data (struct CadetChannel *ch,
        buf_len,
        GCCH_2s (ch));
   crm->qe = GCT_send (ch->t,
-                      &crm->data_message.header,
+                      &crm->data_message->header,
                       &data_sent_cb,
                       crm);
   return GNUNET_OK;
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index ce0178bd5..3a1042eba 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -563,7 +563,7 @@ tmt_rdy (void *cls, size_t size, void *buf)
     return 0;
   }
   msg->size = htons (msg_size);
-  msg->type = htons (1);
+  msg->type = htons (GNUNET_MESSAGE_TYPE_DUMMY);
   data = (uint32_t *) &msg[1];
   *data = htonl (counter);
   if (GNUNET_NO == initialized)
@@ -633,7 +633,8 @@ data_callback (void *cls,
   {
     if (NULL != disconnect_task)
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_INFO, " reschedule timeout\n");
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  " reschedule timeout\n");
       GNUNET_SCHEDULER_cancel (disconnect_task);
       disconnect_task = GNUNET_SCHEDULER_add_delayed (SHORT_TIME,
                                                       &gather_stats_and_exit,
@@ -756,7 +757,9 @@ data_callback (void *cls,
  * {callback_function, message_type, size_expected}
  */
 static struct GNUNET_CADET_MessageHandler handlers[] = {
-  {&data_callback, 1, sizeof (struct GNUNET_MessageHeader)},
+  {&data_callback,
+   GNUNET_MESSAGE_TYPE_DUMMY,
+   sizeof (struct GNUNET_MessageHeader)},
   {NULL, 0, 0}
 };
 

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]