[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: avoid cmp pointers, cmp ccn
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: avoid cmp pointers, cmp ccn instead, as client may literally be the same |
Date: |
Mon, 23 Jan 2017 23:17:42 +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 3ceefffec avoid cmp pointers, cmp ccn instead, as client may literally
be the same
3ceefffec is described below
commit 3ceefffec0e038099c3fabfea70d0f9202e298d2
Author: Christian Grothoff <address@hidden>
AuthorDate: Mon Jan 23 23:17:38 2017 +0100
avoid cmp pointers, cmp ccn instead, as client may literally be the same
---
src/cadet/cadet.h | 2 +-
src/cadet/cadet_api.c | 68 ++++++++++++----------------
src/cadet/gnunet-service-cadet-new.c | 7 +--
src/cadet/gnunet-service-cadet-new_channel.c | 58 ++++++++++++++++++------
src/cadet/gnunet-service-cadet-new_channel.h | 4 +-
src/cadet/gnunet-service-cadet-new_tunnels.c | 2 +-
6 files changed, 82 insertions(+), 59 deletions(-)
diff --git a/src/cadet/cadet.h b/src/cadet/cadet.h
index 97372cb80..451d1f354 100644
--- a/src/cadet/cadet.h
+++ b/src/cadet/cadet.h
@@ -68,7 +68,7 @@ extern "C"
/**
* Minimum value for channel IDs of local clients.
*/
-#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000
+#define GNUNET_CADET_LOCAL_CHANNEL_ID_CLI 0x80000000U
/**
* FIXME.
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index de10d5809..53a954810 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -558,8 +558,9 @@ request_data (void *cls)
size_t osize;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Requesting Data: %u bytes\n",
- th->size);
+ "Requesting Data: %u bytes (allow send is %u)\n",
+ th->size,
+ th->channel->allow_send);
GNUNET_assert (0 < th->channel->allow_send);
th->channel->allow_send--;
@@ -727,41 +728,34 @@ handle_local_data (void *cls,
unsigned int i;
uint16_t type;
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Got a data message!\n");
ch = retrieve_channel (h,
message->ccn);
GNUNET_assert (NULL != ch);
payload = (struct GNUNET_MessageHeader *) &message[1];
- LOG (GNUNET_ERROR_TYPE_DEBUG, " %s data on channel %s [%X]\n",
+ type = ntohs (payload->type);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Got a %s data on channel %s [%X] of type %s\n",
GC_f2s (ntohl (ch->ccn.channel_of_client) >=
GNUNET_CADET_LOCAL_CHANNEL_ID_CLI),
GNUNET_i2s (GNUNET_PEER_resolve2 (ch->peer)),
- ntohl (message->ccn.channel_of_client));
+ ntohl (message->ccn.channel_of_client),
+ GC_m2s (type));
- type = ntohs (payload->type);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " payload type %s\n", GC_m2s (type));
for (i = 0; i < h->n_handlers; i++)
{
handler = &h->message_handlers[i];
- LOG (GNUNET_ERROR_TYPE_DEBUG, " checking handler for type %u\n",
- handler->type);
if (handler->type == type)
{
if (GNUNET_OK !=
handler->callback (h->cls, ch, &ch->ctx, payload))
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "callback caused disconnection\n");
- GNUNET_CADET_channel_destroy (ch);
- break;
- }
- else
- {
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "callback completed successfully\n");
+ "callback caused disconnection\n");
+ GNUNET_CADET_channel_destroy (ch);
break;
}
+ break;
}
}
}
@@ -792,12 +786,11 @@ handle_local_ack (void *cls,
ntohl (ccn.channel_of_client));
return;
}
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Got an ACK on channel %X!\n",
- ntohl (ch->ccn.channel_of_client));
ch->allow_send++;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Checking for pending data\n");
+ "Got an ACK on channel %X, allow send now %u!\n",
+ ntohl (ch->ccn.channel_of_client),
+ ch->allow_send);
for (th = h->th_head; NULL != th; th = th->next)
{
if ( (th->channel == ch) &&
@@ -1269,8 +1262,7 @@ handle_get_tunnel (void *cls,
* original state.
*
* @param h handle to the cadet
- *
- * @return GNUNET_YES in case of sucess, GNUNET_NO otherwise (service down...)
+ * @return #GNUNET_YES in case of success, #GNUNET_NO otherwise (service
down...)
*/
static int
do_reconnect (struct GNUNET_CADET_Handle *h)
@@ -1701,17 +1693,17 @@ GNUNET_CADET_notify_transmit_ready (struct
GNUNET_CADET_Channel *channel,
struct GNUNET_CADET_TransmitHandle *th;
GNUNET_assert (NULL != channel);
- GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY\n");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " on channel %X\n", channel->ccn);
- LOG (GNUNET_ERROR_TYPE_DEBUG, " allow_send %d\n", channel->allow_send);
- if (ntohl (channel->ccn.channel_of_client) >=
- GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
- LOG (GNUNET_ERROR_TYPE_DEBUG, " to origin\n");
- else
- LOG (GNUNET_ERROR_TYPE_DEBUG, " to destination\n");
- LOG (GNUNET_ERROR_TYPE_DEBUG, " payload size %u\n", notify_size);
GNUNET_assert (NULL != notify);
+ GNUNET_assert (GNUNET_CONSTANTS_MAX_CADET_MESSAGE_SIZE >= notify_size);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "CADET NOTIFY TRANSMIT READY on channel %X allow_send is %u to %s with
%u bytes\n",
+ channel->ccn,
+ channel->allow_send,
+ (ntohl (channel->ccn.channel_of_client) >=
+ GNUNET_CADET_LOCAL_CHANNEL_ID_CLI)
+ ? "origin"
+ : "destination",
+ (unsigned int) notify_size);
if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us != maxdelay.rel_value_us)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
@@ -1721,15 +1713,15 @@ GNUNET_CADET_notify_transmit_ready (struct
GNUNET_CADET_Channel *channel,
th = GNUNET_new (struct GNUNET_CADET_TransmitHandle);
th->channel = channel;
th->size = notify_size;
- LOG (GNUNET_ERROR_TYPE_DEBUG, " total size %u\n", th->size);
th->notify = notify;
th->notify_cls = notify_cls;
if (0 != channel->allow_send)
- th->request_data_task = GNUNET_SCHEDULER_add_now (&request_data, th);
+ th->request_data_task
+ = GNUNET_SCHEDULER_add_now (&request_data,
+ th);
else
- add_to_queue (channel->cadet, th);
-
- LOG (GNUNET_ERROR_TYPE_DEBUG, "CADET NOTIFY TRANSMIT READY END\n");
+ add_to_queue (channel->cadet,
+ th);
return th;
}
diff --git a/src/cadet/gnunet-service-cadet-new.c
b/src/cadet/gnunet-service-cadet-new.c
index 441511e45..d2c49db15 100644
--- a/src/cadet/gnunet-service-cadet-new.c
+++ b/src/cadet/gnunet-service-cadet-new.c
@@ -292,11 +292,12 @@ GSC_bind (struct CadetClient *c,
ch,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Accepting incoming %s from %s on open port %s (%u)\n",
+ "Accepting incoming %s from %s on open port %s (%u), assigning ccn
%X\n",
GCCH_2s (ch),
GCP_2s (dest),
GNUNET_h2s (port),
- ntohl (options));
+ ntohl (options),
+ ntohl (ccn.channel_of_client));
/* notify local client about incoming connection! */
env = GNUNET_MQ_msg (cm,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_CHANNEL_CREATE);
@@ -715,7 +716,7 @@ handle_data (void *cls,
GCCH_2s (ch));
if (GNUNET_OK !=
GCCH_handle_local_data (ch,
- c,
+ msg->ccn,
buf,
payload_size))
{
diff --git a/src/cadet/gnunet-service-cadet-new_channel.c
b/src/cadet/gnunet-service-cadet-new_channel.c
index 0d2545fb4..e11616af7 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.c
+++ b/src/cadet/gnunet-service-cadet-new_channel.c
@@ -537,7 +537,7 @@ GCCH_channel_local_new (struct CadetClient *owner,
ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER));
ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE));
ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER));
- ch->max_pending_messages = (ch->nobuffer) ? 1 : 32; /* FIXME: 32!? Do not
hardcode! */
+ ch->max_pending_messages = (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not
hardcode! */
ch->owner = owner;
ch->ccn_owner = ccn;
ch->port = *port;
@@ -633,7 +633,7 @@ GCCH_channel_incoming_new (struct CadetTunnel *t,
ch->nobuffer = (0 != (options & GNUNET_CADET_OPTION_NOBUFFER));
ch->reliable = (0 != (options & GNUNET_CADET_OPTION_RELIABLE));
ch->out_of_order = (0 != (options & GNUNET_CADET_OPTION_OUT_OF_ORDER));
- ch->max_pending_messages = (ch->nobuffer) ? 1 : 32; /* FIXME: 32!? Do not
hardcode! */
+ ch->max_pending_messages = (ch->nobuffer) ? 1 : 4; /* FIXME: 4!? Do not
hardcode! */
GNUNET_STATISTICS_update (stats,
"# channels",
1,
@@ -774,21 +774,31 @@ GCCH_handle_duplicate_open (struct CadetChannel *ch)
/**
- * Send a #GNUNET_MESSAGE_TYPE_CADET_LOCAL ACK to the client to solicit more
messages.
+ * Send a #GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK to the client to solicit more
messages.
*
* @param ch channel the ack is for
- * @param c client to send the ACK to
+ * @param to_owner #GNUNET_YES to send to owner,
+ * #GNUNET_NO to send to dest
*/
static void
send_ack_to_client (struct CadetChannel *ch,
- struct CadetClient *c)
+ int to_owner)
{
struct GNUNET_MQ_Envelope *env;
struct GNUNET_CADET_LocalAck *ack;
+ struct CadetClient *c;
env = GNUNET_MQ_msg (ack,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_ACK);
- ack->ccn = (c == ch->owner) ? ch->ccn_owner : ch->ccn_dest;
+ ack->ccn = (GNUNET_YES == to_owner) ? ch->ccn_owner : ch->ccn_dest;
+ c = (GNUNET_YES == to_owner)
+ ? ch->owner
+ : ch->dest;
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending CADET_LOCAL_ACK to %s (%s) at ccn %X\n",
+ GSC_2s (c),
+ (GNUNET_YES == to_owner) ? "owner" : "dest",
+ ntohl (ack->ccn.channel_of_client));
GSC_send_to_client (c,
env);
}
@@ -836,6 +846,8 @@ GCCH_bind (struct CadetChannel *ch,
: GCT_get_destination (ch->t),
&ch->port,
options);
+ GNUNET_assert (ntohl (ch->ccn_dest.channel_of_client) <
+ GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
ch->mid_recv.mid = htonl (1); /* The CONNECT counts as message 0! */
if (GNUNET_YES == ch->is_loopback)
{
@@ -850,9 +862,11 @@ GCCH_bind (struct CadetChannel *ch,
ch);
}
/* give client it's initial supply of ACKs */
+ GNUNET_assert (ntohl (ch->ccn_dest.channel_of_client) <
+ GNUNET_CADET_LOCAL_CHANNEL_ID_CLI);
for (unsigned int i=0;i<ch->max_pending_messages;i++)
send_ack_to_client (ch,
- ch->dest);
+ GNUNET_NO);
}
@@ -938,7 +952,7 @@ GCCH_handle_channel_open_ack (struct CadetChannel *ch)
to be buffered! */
for (unsigned int i=0;i<ch->max_pending_messages;i++)
send_ack_to_client (ch,
- ch->owner);
+ GNUNET_YES);
break;
case CADET_CHANNEL_READY:
/* duplicate ACK, maybe we retried the CREATE. Ignore. */
@@ -1121,7 +1135,9 @@ GCCH_handle_channel_plaintext_data_ack (struct
CadetChannel *ch,
(unsigned int) ntohl (ack->mid.mid),
ch->pending_messages);
send_ack_to_client (ch,
- (NULL == ch->owner) ? ch->dest : ch->owner);
+ (NULL == ch->owner)
+ ? GNUNET_NO
+ : GNUNET_YES);
}
@@ -1316,7 +1332,7 @@ data_sent_cb (void *cls)
* buffer space in the tunnel.
*
* @param ch Channel.
- * @param sender client sending the data
+ * @param sender_ccn ccn of the sender
* @param buf payload to transmit.
* @param buf_len number of bytes in @a buf
* @return #GNUNET_OK if everything goes well,
@@ -1324,7 +1340,7 @@ data_sent_cb (void *cls)
*/
int
GCCH_handle_local_data (struct CadetChannel *ch,
- struct CadetClient *sender,
+ struct GNUNET_CADET_ClientChannelNumber sender_ccn,
const char *buf,
size_t buf_len)
{
@@ -1342,12 +1358,26 @@ GCCH_handle_local_data (struct CadetChannel *ch,
struct CadetClient *receiver;
struct GNUNET_MQ_Envelope *env;
struct GNUNET_CADET_LocalData *ld;
+ int to_owner;
env = GNUNET_MQ_msg_extra (ld,
buf_len,
GNUNET_MESSAGE_TYPE_CADET_LOCAL_DATA);
- receiver = (ch->owner == sender) ? ch->dest : ch->owner;
- ld->ccn = (ch->owner == sender) ? ch->ccn_dest : ch->ccn_owner;
+ if (sender_ccn.channel_of_client ==
+ ch->ccn_owner.channel_of_client)
+ {
+ receiver = ch->dest;
+ ld->ccn = ch->ccn_dest;
+ to_owner = GNUNET_NO;
+ }
+ else
+ {
+ GNUNET_assert (sender_ccn.channel_of_client ==
+ ch->ccn_dest.channel_of_client);
+ receiver = ch->owner;
+ ld->ccn = ch->ccn_owner;
+ to_owner = GNUNET_YES;
+ }
GNUNET_memcpy (&ld[1],
buf,
buf_len);
@@ -1355,7 +1385,7 @@ GCCH_handle_local_data (struct CadetChannel *ch,
GSC_send_to_client (receiver,
env);
send_ack_to_client (ch,
- sender);
+ to_owner);
return GNUNET_OK;
}
diff --git a/src/cadet/gnunet-service-cadet-new_channel.h
b/src/cadet/gnunet-service-cadet-new_channel.h
index 99124f651..d1b854570 100644
--- a/src/cadet/gnunet-service-cadet-new_channel.h
+++ b/src/cadet/gnunet-service-cadet-new_channel.h
@@ -220,7 +220,7 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch);
* buffer space in the tunnel.
*
* @param ch Channel.
- * @param sender client sending the data
+ * @param sender_ccn ccn of the sender
* @param buf payload to transmit.
* @param buf_len number of bytes in @a buf
* @return #GNUNET_OK if everything goes well,
@@ -228,7 +228,7 @@ GCCH_handle_remote_destroy (struct CadetChannel *ch);
*/
int
GCCH_handle_local_data (struct CadetChannel *ch,
- struct CadetClient *sender,
+ struct GNUNET_CADET_ClientChannelNumber sender_ccn,
const char *buf,
size_t buf_len);
diff --git a/src/cadet/gnunet-service-cadet-new_tunnels.c
b/src/cadet/gnunet-service-cadet-new_tunnels.c
index 8418dc50d..c6a8b8962 100644
--- a/src/cadet/gnunet-service-cadet-new_tunnels.c
+++ b/src/cadet/gnunet-service-cadet-new_tunnels.c
@@ -2154,7 +2154,7 @@ handle_plaintext_channel_open_ack (void *cls,
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Receicved channel OPEN_ACK on channel %s from %s\n",
+ "Received channel OPEN_ACK on channel %s from %s\n",
GCCH_2s (ch),
GCT_2s (t));
GCCH_handle_channel_open_ack (ch);
--
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: avoid cmp pointers, cmp ccn instead, as client may literally be the same,
gnunet <=