[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27912 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27912 - gnunet/src/transport |
Date: |
Thu, 11 Jul 2013 14:06:25 +0200 |
Author: wachs
Date: 2013-07-11 14:06:25 +0200 (Thu, 11 Jul 2013)
New Revision: 27912
Modified:
gnunet/src/transport/plugin_transport_udp.c
Log:
fixed:
printing of inbound session
size of inbound sessions
Modified: gnunet/src/transport/plugin_transport_udp.c
===================================================================
--- gnunet/src/transport/plugin_transport_udp.c 2013-07-11 12:03:27 UTC (rev
27911)
+++ gnunet/src/transport/plugin_transport_udp.c 2013-07-11 12:06:25 UTC (rev
27912)
@@ -153,6 +153,8 @@
unsigned int rc;
int in_destroy;
+
+ int inbound;
};
@@ -545,6 +547,11 @@
memcpy (&a4, &t4->ipv4_addr, sizeof (a4));
sb = &a4;
}
+ else if (addrlen == 0)
+ {
+ GNUNET_snprintf (rbuf, sizeof (rbuf), "%s", "<inbound>");
+ return rbuf;
+ }
else
{
GNUNET_break_op (0);
@@ -1378,6 +1385,7 @@
s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS;
s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO_ABS;
s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO;
+ s->inbound = GNUNET_NO;
start_session_timeout (s);
return s;
}
@@ -1451,10 +1459,9 @@
* @return the session or NULL of max connections exceeded
*/
static struct Session *
-udp_plugin_get_session (void *cls,
- const struct GNUNET_HELLO_Address *address)
+udp_plugin_lookup_session (void *cls,
+ const struct GNUNET_HELLO_Address *address)
{
- struct Session * s = NULL;
struct Plugin * plugin = cls;
struct IPv6UdpAddress * udp_a6;
struct IPv4UdpAddress * udp_a4;
@@ -1507,7 +1514,15 @@
LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res);
return cctx.res;
}
+ return NULL;
+}
+static struct Session *
+udp_plugin_create_session (void *cls,
+ const struct GNUNET_HELLO_Address *address)
+{
+ struct Session * s = NULL;
+
/* otherwise create new */
s = create_session (plugin,
&address->peer,
@@ -1524,8 +1539,6 @@
&s->target.hashPubKey,
s,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE));
- plugin->env->session_start (NULL, &address->peer, PLUGIN_NAME,
- address->address, address->address_length, s, NULL, 0);
GNUNET_STATISTICS_set(plugin->env->stats,
"# UDP, sessions active",
GNUNET_CONTAINER_multihashmap_size(plugin->sessions),
@@ -1533,6 +1546,30 @@
return s;
}
+
+
+/**
+ * Creates a new outbound session the transport service will use to send data
to the
+ * peer
+ *
+ * @param cls the plugin
+ * @param address the address
+ * @return the session or NULL of max connections exceeded
+ */
+static struct Session *
+udp_plugin_get_session (void *cls,
+ const struct GNUNET_HELLO_Address *address)
+{
+ struct Session * s = NULL;
+
+ /* otherwise create new */
+ if (NULL != (s = udp_plugin_lookup_session(cls, address)))
+ return s;
+ else
+ return udp_plugin_create_session (cls, address);
+}
+
+
static void
enqueue (struct Plugin *plugin, struct UDP_MessageWrapper * udpw)
{
@@ -1830,13 +1867,13 @@
&si->sender,
hdr,
si->session,
- si->arg,
- si->args);
+ (GNUNET_YES == si->session->inbound) ? NULL : si->arg,
+ (GNUNET_YES == si->session->inbound) ? 0 : si->args);
plugin->env->update_address_metrics (plugin->env->cls,
&si->sender,
- si->arg,
- si->args,
+ (GNUNET_YES == si->session->inbound) ?
NULL : si->arg,
+ (GNUNET_YES == si->session->inbound) ?
0 : si->args,
si->session,
&si->session->ats, 1);
@@ -1909,7 +1946,15 @@
GNUNET_a2s (sender_addr, sender_addr_len));
struct GNUNET_HELLO_Address * address =
GNUNET_HELLO_address_allocate(&msg->sender, "udp", arg, args);
- s = udp_plugin_get_session(plugin, address);
+ if (NULL == (s = udp_plugin_lookup_session (plugin, address)))
+ {
+ s = udp_plugin_create_session(plugin, address);
+ s->inbound = GNUNET_YES;
+ plugin->env->session_start (NULL, &address->peer, PLUGIN_NAME,
+ (GNUNET_YES == s->inbound) ? NULL : address->address,
+ (GNUNET_YES == s->inbound) ? 0 :
address->address_length,
+ s, NULL, 0);
+ }
GNUNET_free (address);
/* iterate over all embedded messages */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27912 - gnunet/src/transport,
gnunet <=