[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34708 - in gnunet/src: multicast psyc
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34708 - in gnunet/src: multicast psyc |
Date: |
Fri, 19 Dec 2014 23:48:34 +0100 |
Author: grothoff
Date: 2014-12-19 23:48:34 +0100 (Fri, 19 Dec 2014)
New Revision: 34708
Modified:
gnunet/src/multicast/gnunet-service-multicast.c
gnunet/src/psyc/psyc_api.c
Log:
-support join_msg=NULL properly
Modified: gnunet/src/multicast/gnunet-service-multicast.c
===================================================================
--- gnunet/src/multicast/gnunet-service-multicast.c 2014-12-19 22:43:58 UTC
(rev 34707)
+++ gnunet/src/multicast/gnunet-service-multicast.c 2014-12-19 22:48:34 UTC
(rev 34708)
@@ -943,10 +943,18 @@
{
struct Group *
grp = GNUNET_SERVER_client_get_user_context (client, struct Group);
+ const struct GNUNET_MULTICAST_MessageHeader *
+ msg = (const struct GNUNET_MULTICAST_MessageHeader *) m;
+ struct Origin *orig;
+
+ if (NULL == grp)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
GNUNET_assert (GNUNET_YES == grp->is_origin);
- struct Origin *orig = (struct Origin *) grp;
- struct GNUNET_MULTICAST_MessageHeader *
- msg = (struct GNUNET_MULTICAST_MessageHeader *) m;
+ orig = (struct Origin *) grp;
msg->fragment_id = GNUNET_htonll (++orig->max_fragment_id);
msg->purpose.size = htonl (ntohs (msg->header.size)
@@ -975,14 +983,20 @@
client_recv_multicast_request (void *cls, struct GNUNET_SERVER_Client *client,
const struct GNUNET_MessageHeader *m)
{
- struct Group *
- grp = GNUNET_SERVER_client_get_user_context (client, struct Group);
+ struct Group *grp = GNUNET_SERVER_client_get_user_context (client, struct
Group);
+ struct Member *mem;
+ const struct GNUNET_MULTICAST_RequestHeader *
+ req = (const struct GNUNET_MULTICAST_RequestHeader *) m;
+
+ if (NULL == grp)
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
GNUNET_assert (GNUNET_NO == grp->is_origin);
- struct Member *mem = (struct Member *) grp;
+ mem = (struct Member *) grp;
- struct GNUNET_MULTICAST_RequestHeader *
- req = (struct GNUNET_MULTICAST_RequestHeader *) m;
-
req->fragment_id = GNUNET_ntohll (++mem->max_fragment_id);
req->purpose.size = htonl (ntohs (req->header.size)
- sizeof (req->header)
Modified: gnunet/src/psyc/psyc_api.c
===================================================================
--- gnunet/src/psyc/psyc_api.c 2014-12-19 22:43:58 UTC (rev 34707)
+++ gnunet/src/psyc/psyc_api.c 2014-12-19 22:48:34 UTC (rev 34708)
@@ -854,11 +854,15 @@
{
struct GNUNET_PSYC_Slave *slv = GNUNET_malloc (sizeof (*slv));
struct GNUNET_PSYC_Channel *chn = &slv->chn;
+ uint16_t relay_size = relay_count * sizeof (*relays);
+ uint16_t join_msg_size;
+ struct SlaveJoinRequest *req;
- uint16_t relay_size = relay_count * sizeof (*relays);
- uint16_t join_msg_size = ntohs (join_msg->header.size);
- struct SlaveJoinRequest *req
- = GNUNET_malloc (sizeof (*req) + relay_size + join_msg_size);
+ if (NULL == join_msg)
+ join_msg_size = 0;
+ else
+ join_msg_size = ntohs (join_msg->header.size);
+ req = GNUNET_malloc (sizeof (*req) + relay_size + join_msg_size);
req->header.size = htons (sizeof (*req)
+ relay_count * sizeof (*relays));
req->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN);
@@ -870,8 +874,10 @@
if (0 < relay_size)
memcpy (&req[1], relays, relay_size);
- if (0 < join_msg_size)
- memcpy ((char *) &req[1] + relay_size, join_msg, join_msg_size);
+ if (NULL != join_msg)
+ memcpy ((char *) &req[1] + relay_size,
+ join_msg,
+ join_msg_size);
chn->connect_msg = (struct GNUNET_MessageHeader *) req;
chn->cfg = cfg;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34708 - in gnunet/src: multicast psyc,
gnunet <=