[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r19437 - gnunet/src/transport
From: |
gnunet |
Subject: |
[GNUnet-SVN] r19437 - gnunet/src/transport |
Date: |
Thu, 26 Jan 2012 15:09:44 +0100 |
Author: wachs
Date: 2012-01-26 15:09:44 +0100 (Thu, 26 Jan 2012)
New Revision: 19437
Modified:
gnunet/src/transport/gnunet-service-transport_neighbours.c
gnunet/src/transport/plugin_transport_http.c
gnunet/src/transport/plugin_transport_http_server.c
Log:
implemented session based sending in transport service (coexisting with old
code)
Modified: gnunet/src/transport/gnunet-service-transport_neighbours.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport_neighbours.c 2012-01-26
14:01:56 UTC (rev 19436)
+++ gnunet/src/transport/gnunet-service-transport_neighbours.c 2012-01-26
14:09:44 UTC (rev 19437)
@@ -630,6 +630,11 @@
const struct GNUNET_HELLO_Address *address, int
force_address,
GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls)
{
+#if TEST_NEW_CODE
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Call to depracted function send_with_plugin\n");
+#endif
+
struct GNUNET_TRANSPORT_PluginFunctions *papi;
size_t ret = GNUNET_SYSERR;
@@ -787,10 +792,19 @@
return;
}
- ret =
- send_with_plugin (&n->id, mq->message_buf, mq->message_buf_size, 0,
- timeout, n->session, n->address, GNUNET_YES,
- &transmit_send_continuation, mq);
+#if TEST_NEW_CODE
+ ret = send_with_session(n, n->session,
+ mq->message_buf, mq->message_buf_size,
+ 0, timeout,
+ &transmit_send_continuation, mq);
+#else
+ ret = send_with_plugin (&n->id,
+ mq->message_buf, mq->message_buf_size,
+ 0, timeout,
+ n->session, n->address, GNUNET_YES,
+ &transmit_send_continuation, mq);
+#endif
+
if (ret == -1)
{
/* failure, but 'send' would not call continuation in this case,
@@ -849,9 +863,7 @@
static int
-send_disconnect (const struct GNUNET_PeerIdentity *target,
- const struct GNUNET_HELLO_Address *address,
- struct Session *session)
+send_disconnect (struct NeighbourMapEntry * n)
{
size_t ret;
struct SessionDisconnectMessage disconnect_msg;
@@ -880,11 +892,18 @@
&disconnect_msg.purpose,
&disconnect_msg.signature));
- ret =
- send_with_plugin (target, (const char *) &disconnect_msg,
- sizeof (disconnect_msg), UINT32_MAX,
- GNUNET_TIME_UNIT_FOREVER_REL, session, address,
+#if TEST_NEW_CODE
+ ret = send_with_session (n,n->session,
+ (const char *) &disconnect_msg, sizeof (disconnect_msg),
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ &send_disconnect_cont, NULL);
+#else
+ ret = send_with_plugin (&n->id,
+ (const char *) &disconnect_msg, sizeof
(disconnect_msg),
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ n->session, n->address,
GNUNET_YES, &send_disconnect_cont, NULL);
+#endif
if (ret == GNUNET_SYSERR)
return GNUNET_SYSERR;
@@ -916,7 +935,7 @@
/* send DISCONNECT MESSAGE */
if (previous_state == S_CONNECTED)
{
- if (GNUNET_OK == send_disconnect (&n->id, n->address, n->session))
+ if (GNUNET_OK == send_disconnect (n))
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent DISCONNECT_MSG to `%s'\n",
GNUNET_i2s (&n->id));
else
@@ -1060,12 +1079,18 @@
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE);
-
- ret =
- send_with_plugin (&n->id, (const void *) &m, sizeof (m),
+#if TEST_NEW_CODE
+ ret = send_with_session (n,n->session,
+ (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ NULL, NULL);
+#else
+ ret = send_with_plugin (&n->id, (const void *) &m, sizeof (m),
UINT32_MAX /* priority */ ,
GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
GNUNET_YES, NULL, NULL);
+#endif
n->expect_latency_response = GNUNET_NO;
n->keep_alive_sent = GNUNET_TIME_absolute_get_zero ();
@@ -1526,6 +1551,10 @@
n->session, GNUNET_i2s (&n->id), GST_plugins_a2s (n->address));
n->session = session;
}
+ /* remove this dummy */
+ if (NULL != NULL) send_with_plugin (NULL, NULL, 0,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, NULL,
+ NULL, GNUNET_YES, NULL, NULL);
#else
n->session = session;
@@ -1548,10 +1577,19 @@
cc = GNUNET_malloc (sizeof (struct ContinutionContext));
cc->session = session;
cc->address = GNUNET_HELLO_address_copy (address);
- ret =
- send_with_plugin (peer, (const char *) &connect_msg, msg_len,
- UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
- address, GNUNET_YES, &send_connect_continuation, cc);
+
+#if TEST_NEW_CODE
+ ret = send_with_session (n,n->session,
+ (const char *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ &send_connect_continuation, cc);
+#else
+ ret =
+ send_with_plugin (peer, (const char *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
+ address, GNUNET_YES, &send_connect_continuation, cc);
+#endif
+
return GNUNET_NO;
case S_CONNECT_RECV:
/* We received a CONNECT message and asked ATS for an address */
@@ -1592,11 +1630,21 @@
cc = GNUNET_malloc (sizeof (struct ContinutionContext));
cc->session = session;
cc->address = GNUNET_HELLO_address_copy (address);
+
+#if TEST_NEW_CODE
+ ret = send_with_session(n, n->session,
+ (const void *) &connect_msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ &send_switch_address_continuation, cc);
+#else
ret =
send_with_plugin (peer, (const char *) &connect_msg, msg_len,
UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL, session,
address, GNUNET_YES,
&send_switch_address_continuation, cc);
+#endif
+
+
if (ret == GNUNET_SYSERR)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2060,10 +2108,22 @@
m.size = htons (sizeof (struct GNUNET_MessageHeader));
m.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE);
- send_with_plugin (&n->id, (const void *) &m, sizeof (m),
- UINT32_MAX /* priority */ ,
- GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
- GNUNET_YES, NULL, NULL);
+#if TEST_NEW_CODE
+ send_with_session(n, n->session,
+ (const void *) &m, sizeof (m),
+ UINT32_MAX,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ NULL, NULL);
+#else
+ send_with_plugin (&n->id,
+ (const void *) &m, sizeof (m),
+ UINT32_MAX /* priority */ ,
+ GNUNET_TIME_UNIT_FOREVER_REL,
+ n->session, n->address,
+ GNUNET_YES, NULL, NULL);
+#endif
+
+
}
/**
@@ -2444,10 +2504,19 @@
msg.size = htons (msg_len);
msg.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK);
+#if TEST_NEW_CODE
+ ret = send_with_session(n, n->session,
+ (const char *) &msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ NULL, NULL);
+#else
ret =
- send_with_plugin (&n->id, (const char *) &msg, msg_len, UINT32_MAX,
- GNUNET_TIME_UNIT_FOREVER_REL, n->session, n->address,
- GNUNET_YES, NULL, NULL);
+ send_with_plugin (&n->id,
+ (const char *) &msg, msg_len,
+ UINT32_MAX, GNUNET_TIME_UNIT_FOREVER_REL,
+ n->session, n->address, GNUNET_YES,
+ NULL, NULL);
+#endif
if (ret == GNUNET_SYSERR)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2496,7 +2565,6 @@
n = lookup_neighbour (peer);
if (NULL == n)
{
- send_disconnect (peer, address, session);
GNUNET_break (0);
return;
}
Modified: gnunet/src/transport/plugin_transport_http.c
===================================================================
--- gnunet/src/transport/plugin_transport_http.c 2012-01-26 14:01:56 UTC
(rev 19436)
+++ gnunet/src/transport/plugin_transport_http.c 2012-01-26 14:09:44 UTC
(rev 19437)
@@ -532,7 +532,7 @@
}
/**
- * Creates a new session the transport service will use to send data to the
+ * Creates a new outbound session the transport service will use to send data
to the
* peer
*
* @param cls the plugin
@@ -579,7 +579,7 @@
s->addrlen = addrlen;
s->next = NULL;
s->next_receive = GNUNET_TIME_absolute_get_zero ();
-
+ s->inbound = GNUNET_NO;
s->ats_address_network_type = htonl (GNUNET_ATS_NET_UNSPECIFIED);
/* Get ATS type */
@@ -616,11 +616,12 @@
/* initiate new connection */
if (GNUNET_SYSERR == client_connect (s))
{
- if (s != NULL)
- {
- GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
- delete_session (s);
- }
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name,
+ "Cannot connect to peer `%s' address `%s''\n",
+ http_plugin_address_to_string(NULL, s->addr, s->addrlen),
+ GNUNET_i2s (&s->target));
+ GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
+ delete_session (s);
return NULL;
}
@@ -676,8 +677,8 @@
{
if ((tmp == session) &&
(0 == memcmp (&session->target, &tmp->target, sizeof (struct
GNUNET_PeerIdentity))) &&
- (session->addrlen != tmp->addrlen) &&
- (0 != memcmp (session->addr, tmp->addr, tmp->addrlen)))
+ (session->addrlen == tmp->addrlen) &&
+ (0 == memcmp (session->addr, tmp->addr, tmp->addrlen)))
break;
tmp = tmp->next;
}
Modified: gnunet/src/transport/plugin_transport_http_server.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_server.c 2012-01-26 14:01:56 UTC
(rev 19436)
+++ gnunet/src/transport/plugin_transport_http_server.c 2012-01-26 14:09:44 UTC
(rev 19437)
@@ -379,7 +379,7 @@
struct GNUNET_PeerIdentity target;
int check = GNUNET_NO;
uint32_t tag = 0;
- int direction;
+ int direction = GNUNET_SYSERR;
conn_info =
MHD_get_connection_info (mhd_connection,
@@ -410,7 +410,10 @@
else if (0 == strcmp (MHD_HTTP_METHOD_GET, method))
direction = _SEND;
else
+ {
GNUNET_break_op (0);
+ goto error;
+ }
if (check == GNUNET_NO)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r19437 - gnunet/src/transport,
gnunet <=