[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: fix leaks, note that APIs a
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: fix leaks, note that APIs are deprecated (NTR instead of MQ style) |
Date: |
Mon, 13 Mar 2017 18:30:15 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new e7739331e fix leaks, note that APIs are deprecated (NTR instead of MQ
style)
e7739331e is described below
commit e7739331e20a0ec26febd6d4268323d3b0638341
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Mar 13 18:32:03 2017 +0100
fix leaks, note that APIs are deprecated (NTR instead of MQ style)
---
src/include/gnunet_multicast_service.h | 4 ++
src/multicast/test_multicast_2peers.c | 70 +++++++++++++++++++---------------
2 files changed, 44 insertions(+), 30 deletions(-)
diff --git a/src/include/gnunet_multicast_service.h
b/src/include/gnunet_multicast_service.h
index 3829a7040..5645207dd 100644
--- a/src/include/gnunet_multicast_service.h
+++ b/src/include/gnunet_multicast_service.h
@@ -617,6 +617,7 @@ GNUNET_MULTICAST_origin_start (const struct
GNUNET_CONFIGURATION_Handle *cfg,
* data. If 0 is returned in @a data_size the transmission is paused,
* and can be resumed with GNUNET_MULTICAST_origin_to_all_resume().
* #GNUNET_YES if this completes the transmission (all data supplied)
+ * @deprecated should move to MQ-style API!
*/
typedef int
(*GNUNET_MULTICAST_OriginTransmitNotify) (void *cls,
@@ -647,6 +648,7 @@ struct GNUNET_MULTICAST_OriginTransmitHandle;
* Closure for @a notify.
*
* @return NULL on error (i.e. request already pending).
+ * @deprecated should move to MQ-style API!
*/
struct GNUNET_MULTICAST_OriginTransmitHandle *
GNUNET_MULTICAST_origin_to_all (struct GNUNET_MULTICAST_Origin *origin,
@@ -854,6 +856,7 @@ GNUNET_MULTICAST_member_part (struct
GNUNET_MULTICAST_Member *member,
* data. If 0 is returned in @a data_size the transmission is paused,
* and can be resumed with GNUNET_MULTICAST_member_to_origin_resume().
* #GNUNET_YES if this completes the transmission (all data supplied)
+ * @deprecated should move to MQ-style API!
*/
typedef int
(*GNUNET_MULTICAST_MemberTransmitNotify) (void *cls,
@@ -880,6 +883,7 @@ struct GNUNET_MULTICAST_MemberTransmitHandle;
* Closure for @a notify.
*
* @return Handle to cancel request, NULL on error (i.e. request already
pending).
+ * @deprecated should move to MQ-style API!
*/
struct GNUNET_MULTICAST_MemberTransmitHandle *
GNUNET_MULTICAST_member_to_origin (struct GNUNET_MULTICAST_Member *member,
diff --git a/src/multicast/test_multicast_2peers.c
b/src/multicast/test_multicast_2peers.c
index 02e60a905..058533e50 100644
--- a/src/multicast/test_multicast_2peers.c
+++ b/src/multicast/test_multicast_2peers.c
@@ -20,7 +20,7 @@
/**
* @file multicast/test_multicast_2peers.c
- * @brief Tests for the Multicast API with two peers doing the ping
+ * @brief Tests for the Multicast API with two peers doing the ping
* pong test.
* @author xrs
*/
@@ -117,16 +117,18 @@ member_join_request (void *cls,
}
-int notify (void *cls,
- size_t *data_size,
- void *data)
+
+static int
+notify (void *cls,
+ size_t *data_size,
+ void *data)
{
char text[] = "ping";
*data_size = strlen(text)+1;
GNUNET_memcpy(data, text, *data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Member sents message to origin: %s\n", text);
return GNUNET_YES;
@@ -141,25 +143,30 @@ member_join_decision (void *cls,
const struct GNUNET_PeerIdentity *relays,
const struct GNUNET_MessageHeader *join_msg)
{
- struct GNUNET_MULTICAST_MemberTransmitHandle *req;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Member received a decision from origin: %s\n", (GNUNET_YES ==
is_admitted)?"accepted":"rejected");
-
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Member received a decision from origin: %s\n",
+ (GNUNET_YES == is_admitted)
+ ? "accepted"
+ : "rejected");
+
if (GNUNET_YES == is_admitted)
{
+ struct GNUNET_MULTICAST_MemberTransmitHandle *req;
+
+ // FIXME: move to MQ-style API!
req = GNUNET_MULTICAST_member_to_origin (member,
0,
- notify,
+ ¬ify,
NULL);
}
}
+
static void
-member_message (void *cls,
+member_message (void *cls,
const struct GNUNET_MULTICAST_MessageHeader *msg)
{
- if (0 != strncmp ("pong", (char *)&msg[1], 4))
+ if (0 != strncmp ("pong", (char *)&msg[1], 4))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "member did not receive pong\n");
result = GNUNET_SYSERR;
@@ -184,19 +191,19 @@ origin_join_request (void *cls,
uint8_t data_size = ntohs (join_msg->size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin got a join request...\n");
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin receives: '%s'\n", (char *)&join_msg[1]);
- char data[] = "Come in!";
+ const char data[] = "Come in!";
data_size = strlen (data) + 1;
join_resp = GNUNET_malloc (sizeof (join_resp) + data_size);
join_resp->size = htons (sizeof (join_resp) + data_size);
join_resp->type = htons (123);
GNUNET_memcpy (&join_resp[1], data, data_size);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"origin sends: '%s'\n", data);
GNUNET_MULTICAST_join_decision (jh,
@@ -204,22 +211,22 @@ origin_join_request (void *cls,
0,
NULL,
join_resp);
-
+ GNUNET_free (join_resp);
result = GNUNET_OK;
}
int
-origin_notify (void *cls,
- size_t *data_size,
+origin_notify (void *cls,
+ size_t *data_size,
void *data)
{
char text[] = "pong";
*data_size = strlen(text)+1;
- memcpy(data, text, *data_size);
+ memcpy(data, text, *data_size);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends (to all): %s\n", text);
- return GNUNET_YES;
+ return GNUNET_YES;
}
@@ -228,8 +235,8 @@ origin_request (void *cls,
const struct GNUNET_MULTICAST_RequestHeader *req)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin receives: %s\n", (char
*)&req[1]);
-
- if (0 != strncmp ("ping", (char *)&req[1], 4))
+
+ if (0 != strncmp ("ping", (char *)&req[1], 4))
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "origin didn't reveice a correct
request");
GNUNET_MULTICAST_origin_to_all (origin,
@@ -241,7 +248,7 @@ origin_request (void *cls,
static void
origin_message (void *cls,
- const struct GNUNET_MULTICAST_MessageHeader *msg)
+ const struct GNUNET_MULTICAST_MessageHeader *msg)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin message msg\n");
}
@@ -255,7 +262,7 @@ service_connect1 (void *cls,
{
member = ca_result;
- if (NULL != member)
+ if (NULL != member)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to multicast service of
member\n");
}
@@ -282,11 +289,12 @@ multicast_ca1 (void *cls,
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_MessageHeader *join_msg;
+ void *ret;
// Get members keys
member_key = GNUNET_CRYPTO_ecdsa_key_create ();
GNUNET_CRYPTO_ecdsa_key_get_public (member_key, &member_pub_key);
-
+
char data[] = "Hi, can I enter?";
uint8_t data_size = strlen (data) + 1;
join_msg = GNUNET_malloc (sizeof (join_msg) + data_size);
@@ -297,7 +305,7 @@ multicast_ca1 (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Members tries to join multicast group\n");
- return GNUNET_MULTICAST_member_join (cfg,
+ ret = GNUNET_MULTICAST_member_join (cfg,
&group_pub_key,
member_key,
peer_id[0],
@@ -310,6 +318,8 @@ multicast_ca1 (void *cls,
NULL, /* no test for member_replay_msg
*/
member_message,
NULL);
+ GNUNET_free (join_msg);
+ return ret;
}
@@ -321,7 +331,7 @@ peer_information_cb (void *cls,
{
int i = (int) (long) cls;
- if (NULL == pinfo)
+ if (NULL == pinfo)
{
result = GNUNET_SYSERR;
GNUNET_SCHEDULER_shutdown ();
@@ -335,7 +345,7 @@ peer_information_cb (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Create member peer\n");
- if (0 == i)
+ if (0 == i)
{
/* connect to multicast service of member */
op1 = GNUNET_TESTBED_service_connect (NULL, /* Closure
for operation */
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: fix leaks, note that APIs are deprecated (NTR instead of MQ style),
gnunet <=