[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 14/14: W32: Fix msg allocation in gns helper servi
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 14/14: W32: Fix msg allocation in gns helper service |
Date: |
Sat, 25 Feb 2017 22:05:04 +0100 |
This is an automated email from the git hooks/post-receive script.
lrn pushed a commit to branch master
in repository gnunet.
commit 903c035f7948d1c216d2d85a68458572b0b17e36
Author: Руслан Ижбулатов <address@hidden>
AuthorDate: Sat Feb 25 12:57:37 2017 +0000
W32: Fix msg allocation in gns helper service
The code was hacky, and GCC warned about variables being used without
initialization. Turns out, it was much worse.
---
src/gns/gnunet-gns-helper-service-w32.c | 50 +++++++++------------------------
1 file changed, 13 insertions(+), 37 deletions(-)
diff --git a/src/gns/gnunet-gns-helper-service-w32.c
b/src/gns/gnunet-gns-helper-service-w32.c
index 33de2aab6..a59cc5981 100644
--- a/src/gns/gnunet-gns-helper-service-w32.c
+++ b/src/gns/gnunet-gns-helper-service-w32.c
@@ -154,27 +154,6 @@ do_shutdown (void *cls)
}
-/**
- * Transmit the given message to the client.
- *
- * @param client target of the message
- * @param msg message to transmit, will be freed!
- */
-static void
-transmit (struct GNUNET_SERVICE_Client *client,
- struct GNUNET_MessageHeader *msg)
-{
- struct GNUNET_MQ_Handle *mq = GNUNET_SERVICE_client_get_mq (client);
- struct GNUNET_MQ_Envelope *env;
-
- /* NOTE: small hack here, should have constructed and
- passed an 'env' in the first place... */
- env = GNUNET_MQ_msg_copy (msg);
- GNUNET_MQ_send (mq,
- env);
-}
-
-
#define MarshallPtr(ptr, base, type) \
if (ptr) \
ptr = (type *) ((char *) ptr - (char *) base)
@@ -222,7 +201,9 @@ process_lookup_result (void *cls,
struct request *rq = cls;
int i, j, csanum;
struct GNUNET_W32RESOLVER_GetMessage *msg;
+ struct GNUNET_MQ_Envelope *msg_env;
struct GNUNET_MessageHeader *msgend;
+ struct GNUNET_MQ_Envelope *msgend_env;
WSAQUERYSETW *qs;
size_t size;
size_t size_recalc;
@@ -239,11 +220,9 @@ process_lookup_result (void *cls,
if (0 == rd_count)
{
- msg = GNUNET_new (struct GNUNET_MessageHeader);
- msg->header.size = htons (sizeof (struct GNUNET_MessageHeader));
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
- transmit (rq->client,
- &msg->header);
+ msgend_env = GNUNET_MQ_msg (msgend,
GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (rq->client),
+ msgend_env);
GNUNET_CONTAINER_DLL_remove (rq_head,
rq_tail,
rq);
@@ -304,9 +283,9 @@ process_lookup_result (void *cls,
size += blobsize;
}
size_recalc = sizeof (struct GNUNET_W32RESOLVER_GetMessage) + sizeof
(WSAQUERYSETW);
- msg = GNUNET_malloc (size);
- msg->header.size = htons (size - sizeof (struct GNUNET_MessageHeader));
- msg->header.type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
+ msg_env = GNUNET_MQ_msg_extra (msg,
+ size - sizeof (struct GNUNET_MessageHeader),
+ GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
msg->af = htonl (rq->af);
msg->sc_data1 = htonl (rq->sc.Data1);
msg->sc_data2 = htons (rq->sc.Data2);
@@ -465,10 +444,7 @@ process_lookup_result (void *cls,
}
he->h_addr_list[j] = NULL;
}
- msgend = GNUNET_new (struct GNUNET_MessageHeader);
-
- msgend->type = htons (GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
- msgend->size = htons (sizeof (struct GNUNET_MessageHeader));
+ msgend_env = GNUNET_MQ_msg (msgend,
GNUNET_MESSAGE_TYPE_W32RESOLVER_RESPONSE);
if ((char *) ptr - (char *) msg != size || size_recalc != size ||
size_recalc != ((char *) ptr - (char *) msg))
{
@@ -479,10 +455,10 @@ process_lookup_result (void *cls,
size_recalc);
}
MarshallWSAQUERYSETW (qs, &rq->sc);
- transmit (rq->client,
- &msg->header);
- transmit (rq->client,
- msgend);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (rq->client),
+ msg_env);
+ GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (rq->client),
+ msgend_env);
GNUNET_CONTAINER_DLL_remove (rq_head,
rq_tail,
rq);
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] branch master updated (a57e7703f -> 903c035f7), gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 04/14: W32: Fix a possible control flow error, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 12/14: Fix an initialization warning (GCC bug 53119), gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 06/14: W32: Fix wrong format strings, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 10/14: W32: Splice GNUNET_memcpy macro into NAT and GNS helpers, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 09/14: Silence a GCC warning in gnunet-nat.c, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 14/14: W32: Fix msg allocation in gns helper service,
gnunet <=
- [GNUnet-SVN] [gnunet] 11/14: W32: cast ntohl() result to uint32_t, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 01/14: W32: adapt the code to GNUNET_memcpy() that returns nothing, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 02/14: Use GNU printf format, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 05/14: W32: Fix the conditaions for the ifconfig function, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 13/14: W32: port gnunet-gns-import to new zone iterator callback API, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 03/14: Shuffle some vars around to fix a warning, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 07/14: W32: placate GCC by initializing lsocks_write_fd to NULL, gnunet, 2017/02/25
- [GNUnet-SVN] [gnunet] 08/14: Link libgnunetblockgroup to libgnunetblock, gnunet, 2017/02/25