handle->current = NULL;
process_pending_message (handle);
+ GNUNET_free(pos->msg);
GNUNET_free (pos);
}
last = pos;
pos = pos->next;
}
- new_message->next = last->next; /* Should always be null */
last->next = new_message;
}
else
{
- new_message->next = handle->pending_list; /* Will always be null */
handle->pending_list = new_message;
}
GNUNET_HashCode uidhash;
struct SendCallbackContext *send_ctx;
-#if DEBUG_DV
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api receives message!\n");
-#endif
-
if (msg == NULL)
{
return; /* Connection closed? */
sender_address_len = ntohl(received_msg->sender_address_len);
GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len));
-#if DEBUG_DV
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api receives message, size checks out!\n");
-#endif
sender_address = GNUNET_malloc(sender_address_len);
memcpy(sender_address, &received_msg[1], sender_address_len);
packed_msg_start = (char *)&received_msg[1];
send_result_msg = (struct GNUNET_DV_SendResultMessage *)msg;
hash_from_uid(ntohl(send_result_msg->uid), &uidhash);
send_ctx = GNUNET_CONTAINER_multihashmap_get(handle->send_callbacks, &uidhash);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "got uid of %u or %u, hash of %s !!!!\n", ntohl(send_result_msg->uid), send_result_msg->uid, GNUNET_h2s(&uidhash));
if ((send_ctx != NULL) && (send_ctx->cont != NULL))
{
-#if DEBUG_DV
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api notifies transport of send result (%u)!\n", ntohl(send_result_msg->result));
-#endif
if (ntohl(send_result_msg->result) == 0)
{
send_ctx->cont(send_ctx->cont_cls, &send_ctx->target, GNUNET_OK);
struct SendCallbackContext *send_ctx;
char *end_of_message;
GNUNET_HashCode uidhash;
-#if DEBUG_DV
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV SEND called with message of size %d, address size %d, total size to send is %d\n", msgbuf_size, addrlen, sizeof(struct GNUNET_DV_SendMessage) + msgbuf_size + addrlen);
-#endif
+ int msize;
+#if DEBUG_DV_MESSAGES
+ dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX);
+#else
dv_handle->uid_gen++;
- msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size);
- msg->header.size = htons(sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size);
+#endif
+
+ msize = sizeof(struct GNUNET_DV_SendMessage) + addrlen + msgbuf_size;
+ msg = GNUNET_malloc(msize);
+ msg->header.size = htons(msize);
msg->header.type = htons(GNUNET_MESSAGE_TYPE_TRANSPORT_DV_SEND);
memcpy(&msg->target, target, sizeof(struct GNUNET_PeerIdentity));
msg->msgbuf_size = htonl(msgbuf_size);
end_of_message = &end_of_message[addrlen];
memcpy(end_of_message, msgbuf, msgbuf_size);
add_pending(dv_handle, msg);
-
send_ctx = GNUNET_malloc(sizeof(struct SendCallbackContext));
-
send_ctx->cont = cont;
-
send_ctx->cont_cls = cont_cls;
memcpy(&send_ctx->target, target, sizeof(struct GNUNET_PeerIdentity));
-
hash_from_uid(dv_handle->uid_gen, &uidhash);
-
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "set uid of %u or %u, hash of %s !!!!\n", dv_handle->uid_gen, htonl(dv_handle->uid_gen), GNUNET_h2s(&uidhash));
GNUNET_CONTAINER_multihashmap_put(dv_handle->send_callbacks, &uidhash, send_ctx, GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
return GNUNET_OK;
if (size >= tsize)
{
memcpy(buf, start_context->message, tsize);
+ GNUNET_free(start_context->message);
+ GNUNET_free(start_context);
return tsize;
}