-ensure stats queues do not grow too big
[oweals/gnunet.git] / src / multicast / multicast_api.c
index 774a8bf70ce36709046ebcd6f355e0fdfb4de26d..ce36ef6f2b423dd67fdf66e5dacce1cac4b4a897 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2012, 2013 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2012, 2013 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -163,7 +163,7 @@ struct GNUNET_MULTICAST_JoinHandle
   /**
    * Public key of the member requesting join.
    */
-  struct GNUNET_CRYPTO_EcdsaPublicKey member_key;
+  struct GNUNET_CRYPTO_EcdsaPublicKey member_pub_key;
 
   /**
    * Peer identity of the member requesting join.
@@ -204,9 +204,10 @@ static void
 group_send_connect_msg (struct GNUNET_MULTICAST_Group *grp)
 {
   uint16_t cmsg_size = ntohs (grp->connect_msg->size);
-  struct GNUNET_MessageHeader * cmsg = GNUNET_malloc (cmsg_size);
+  struct GNUNET_MessageHeader *cmsg = GNUNET_malloc (cmsg_size);
   memcpy (cmsg, grp->connect_msg, cmsg_size);
   GNUNET_CLIENT_MANAGER_transmit_now (grp->client, cmsg);
+  GNUNET_free (cmsg);
 }
 
 
@@ -254,9 +255,9 @@ group_recv_join_request (void *cls,
     jmsg = NULL;
   jh = GNUNET_malloc (sizeof (*jh));
   jh->group = grp;
-  jh->member_key = jreq->member_key;
+  jh->member_pub_key = jreq->member_pub_key;
   jh->peer = jreq->peer;
-  grp->join_req_cb (grp->cb_cls, &jreq->member_key, jmsg, jh);
+  grp->join_req_cb (grp->cb_cls, &jreq->member_pub_key, jmsg, jh);
 }
 
 
@@ -366,7 +367,7 @@ group_recv_replay_request (void *cls,
       struct GNUNET_MULTICAST_ReplayHandle * rh = GNUNET_malloc (sizeof (*rh));
       rh->grp = grp;
       rh->req = *rep;
-      grp->replay_frag_cb (grp->cb_cls, &rep->member_key,
+      grp->replay_frag_cb (grp->cb_cls, &rep->member_pub_key,
                            GNUNET_ntohll (rep->fragment_id),
                            GNUNET_ntohll (rep->flags), rh);
     }
@@ -378,7 +379,7 @@ group_recv_replay_request (void *cls,
       struct GNUNET_MULTICAST_ReplayHandle * rh = GNUNET_malloc (sizeof (*rh));
       rh->grp = grp;
       rh->req = *rep;
-      grp->replay_msg_cb (grp->cb_cls, &rep->member_key,
+      grp->replay_msg_cb (grp->cb_cls, &rep->member_pub_key,
                           GNUNET_ntohll (rep->message_id),
                           GNUNET_ntohll (rep->fragment_offset),
                           GNUNET_ntohll (rep->flags), rh);
@@ -615,7 +616,7 @@ GNUNET_MULTICAST_join_decision (struct GNUNET_MULTICAST_JoinHandle *join,
   hdcsn->header.size = htons (sizeof (*hdcsn) + sizeof (*dcsn)
                               + relay_size + join_resp_size);
   hdcsn->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_JOIN_DECISION);
-  hdcsn->member_key = join->member_key;
+  hdcsn->member_pub_key = join->member_pub_key;
   hdcsn->peer = join->peer;
 
   dcsn = (struct MulticastJoinDecisionMessage *) &hdcsn[1];
@@ -904,6 +905,7 @@ GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *orig,
   struct GNUNET_MULTICAST_OriginTransmitHandle *tmit = &orig->tmit;
   tmit->origin = orig;
   tmit->message_id = message_id;
+  tmit->fragment_offset = 0;
   tmit->group_generation = group_generation;
   tmit->notify = notify;
   tmit->notify_cls = notify_cls;
@@ -995,7 +997,7 @@ GNUNET_MULTICAST_origin_to_all_cancel (struct GNUNET_MULTICAST_OriginTransmitHan
  */
 struct GNUNET_MULTICAST_Member *
 GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
-                              const struct GNUNET_CRYPTO_EddsaPublicKey *group_key,
+                              const struct GNUNET_CRYPTO_EddsaPublicKey *group_pub_key,
                               const struct GNUNET_CRYPTO_EcdsaPrivateKey *member_key,
                               const struct GNUNET_PeerIdentity *origin,
                               uint16_t relay_count,
@@ -1017,7 +1019,7 @@ GNUNET_MULTICAST_member_join (const struct GNUNET_CONFIGURATION_Handle *cfg,
     join = GNUNET_malloc (sizeof (*join) + relay_size + join_msg_size);
   join->header.size = htons (sizeof (*join) + relay_size + join_msg_size);
   join->header.type = htons (GNUNET_MESSAGE_TYPE_MULTICAST_MEMBER_JOIN);
-  join->group_key = *group_key;
+  join->group_pub_key = *group_pub_key;
   join->member_key = *member_key;
   join->origin = *origin;
   join->relay_count = ntohl (relay_count);
@@ -1122,6 +1124,7 @@ GNUNET_MULTICAST_member_replay_fragment (struct GNUNET_MULTICAST_Member *mem,
                                          uint64_t flags)
 {
   member_replay_request (mem, fragment_id, 0, 0, flags);
+  // FIXME: return
 }
 
 
@@ -1150,6 +1153,7 @@ GNUNET_MULTICAST_member_replay_message (struct GNUNET_MULTICAST_Member *mem,
                                         uint64_t flags)
 {
   member_replay_request (mem, 0, message_id, fragment_offset, flags);
+  // FIXME: return
 }
 
 
@@ -1224,6 +1228,7 @@ GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *mem,
   struct GNUNET_MULTICAST_MemberTransmitHandle *tmit = &mem->tmit;
   tmit->member = mem;
   tmit->request_id = request_id;
+  tmit->fragment_offset = 0;
   tmit->notify = notify;
   tmit->notify_cls = notify_cls;