summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-12 19:37:14 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-12 19:37:14 +0000
commita9bc1071776952946505c13fbfca010596261db0 (patch)
treefc5bc5def4af47a9d76735349316d266eee40cb0 /src
parent30b63fcc6c9ab16a15f2f9640f8991e2893d9cef (diff)
-nicer logging
Diffstat (limited to 'src')
-rw-r--r--src/transport/gnunet-service-transport_validation.c103
-rw-r--r--src/transport/plugin_transport_tcp.c29
2 files changed, 65 insertions, 67 deletions
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index 323fd042a..8f563de02 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -517,11 +517,11 @@ transmit_ping_if_allowed (void *cls,
struct GNUNET_TRANSPORT_PluginFunctions *papi;
struct GNUNET_TIME_Absolute next;
const struct GNUNET_MessageHeader *hello;
- enum GNUNET_ATS_Network_Type network;
ssize_t ret;
size_t tsize;
size_t slen;
uint16_t hsize;
+ struct Session *session;
ve->bc = NULL;
if (GNUNET_NO == result)
@@ -542,17 +542,10 @@ transmit_ping_if_allowed (void *cls,
}
hello = GST_hello_get ();
GNUNET_assert (NULL != hello);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting plain PING to `%s' `%s' `%s'\n",
- GNUNET_i2s (pid),
- GST_plugins_a2s (ve->address),
- ve->address->transport_name);
-
slen = strlen (ve->address->transport_name) + 1;
hsize = ntohs (hello->size);
- tsize =
- sizeof (struct TransportPingMessage) + ve->address->address_length +
- slen + hsize;
+ tsize = sizeof (struct TransportPingMessage) +
+ ve->address->address_length + slen + hsize;
ping.header.size =
htons (sizeof (struct TransportPingMessage) +
@@ -570,11 +563,11 @@ transmit_ping_if_allowed (void *cls,
slen + hsize;
}
{
- char message_buf[tsize];
+ char message_buf[tsize] GNUNET_ALIGN;
- /* build message with structure:
- * [HELLO][TransportPingMessage][Transport name][Address] */
- memcpy (message_buf, hello, hsize);
+ memcpy (message_buf,
+ hello,
+ hsize);
memcpy (&message_buf[hsize],
&ping,
sizeof (struct TransportPingMessage));
@@ -585,41 +578,42 @@ transmit_ping_if_allowed (void *cls,
ve->address->address,
ve->address->address_length);
papi = GST_plugins_find (ve->address->transport_name);
- GNUNET_assert (NULL != papi);
- GNUNET_assert (NULL != papi->send);
- struct Session *session = papi->get_session (papi->cls,
- ve->address);
-
- if (NULL != session)
- {
- ret = papi->send (papi->cls, session,
- message_buf, tsize,
- PING_PRIORITY,
- ACCEPTABLE_PING_DELAY,
- NULL, NULL);
- network = papi->get_network (papi->cls, session);
- if (GNUNET_ATS_NET_UNSPECIFIED == network)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Could not obtain a valid network for `%s' `%s'\n",
- GNUNET_i2s (pid),
- GST_plugins_a2s (ve->address));
- GNUNET_break(0);
- }
- GST_neighbours_notify_data_sent (ve->address, session, tsize);
- }
- else
+ session = papi->get_session (papi->cls,
+ ve->address);
+ if (NULL == session)
{
/* Could not get a valid session */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Could not get a valid session for `%s' `%s'\n",
+ "Failed to get session to send PING to `%s' at `%s'\n",
GNUNET_i2s (pid),
GST_plugins_a2s (ve->address));
- ret = -1;
+ return;
}
- }
- if (-1 != ret)
- {
+
+ ret = papi->send (papi->cls, session,
+ message_buf, tsize,
+ PING_PRIORITY,
+ ACCEPTABLE_PING_DELAY,
+ NULL, NULL);
+ if (-1 == ret)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Failed to send PING to `%s' at `%s'\n",
+ GNUNET_i2s (pid),
+ GST_plugins_a2s (ve->address));
+ return;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Transmitted plain PING to `%s' `%s' `%s'\n",
+ GNUNET_i2s (pid),
+ GST_plugins_a2s (ve->address),
+ ve->address->transport_name);
+ ve->network = papi->get_network (papi->cls,
+ session);
+ GNUNET_break (GNUNET_ATS_NET_UNSPECIFIED != ve->network);
+ GST_neighbours_notify_data_sent (ve->address,
+ session,
+ tsize);
next = GNUNET_TIME_relative_to_absolute (validation_delay);
validation_next = GNUNET_TIME_absolute_max (next,
validation_next);
@@ -628,7 +622,6 @@ transmit_ping_if_allowed (void *cls,
gettext_noop ("# PINGs for address validation sent"),
1,
GNUNET_NO);
- ve->network = network;
ve->expecting_pong = GNUNET_YES;
validations_running++;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -639,7 +632,9 @@ transmit_ping_if_allowed (void *cls,
validations_running,
GNUNET_NO);
/* Notify about PING sent */
- validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE);
+ validation_entry_changed (ve,
+ GNUNET_TRANSPORT_VS_UPDATE);
+
}
}
@@ -683,7 +678,7 @@ revalidate_address (void *cls,
{
/* should wait a bit longer */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Waiting for %s longer before validating address `%s'\n",
+ "Waiting for %s longer before (re)validating address `%s'\n",
GNUNET_STRINGS_relative_time_to_string (delay,
GNUNET_YES),
GST_plugins_a2s (ve->address));
@@ -727,7 +722,8 @@ revalidate_address (void *cls,
delay = GNUNET_TIME_relative_add (canonical_delay,
GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_MICROSECONDS, rdelay));
+ (GNUNET_TIME_UNIT_MICROSECONDS,
+ rdelay));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Validating now, next scheduled for %s, now validating address `%s'\n",
@@ -735,7 +731,9 @@ revalidate_address (void *cls,
GNUNET_YES),
GST_plugins_a2s (ve->address));
ve->revalidation_task =
- GNUNET_SCHEDULER_add_delayed (delay, &revalidate_address, ve);
+ GNUNET_SCHEDULER_add_delayed (delay,
+ &revalidate_address,
+ ve);
ve->next_validation = GNUNET_TIME_relative_to_absolute (delay);
/* start PINGing by checking blacklist */
@@ -790,7 +788,8 @@ find_validation_entry (const struct GNUNET_HELLO_Address *address)
ve,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
publish_ve_stat_update ();
- validation_entry_changed (ve, GNUNET_TRANSPORT_VS_NEW);
+ validation_entry_changed (ve,
+ GNUNET_TRANSPORT_VS_NEW);
return ve;
}
@@ -841,7 +840,8 @@ add_valid_address (void *cls,
ve->next_validation = GNUNET_TIME_absolute_get();
ve->revalidation_task = GNUNET_SCHEDULER_add_now (&revalidate_address, ve);
}
- validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE);
+ validation_entry_changed (ve,
+ GNUNET_TRANSPORT_VS_UPDATE);
memset (&prop, 0, sizeof (prop));
prop.scope = ve->network;
prop.delay = GNUNET_TIME_relative_divide (ve->latency, 2);
@@ -1508,7 +1508,8 @@ GST_validation_handle_pong (const struct GNUNET_PeerIdentity *sender,
}
/* Notify about new validity */
- validation_entry_changed (ve, GNUNET_TRANSPORT_VS_UPDATE);
+ validation_entry_changed (ve,
+ GNUNET_TRANSPORT_VS_UPDATE);
/* build HELLO to store in PEERINFO */
ve->copied = GNUNET_NO;
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 19ce855d8..32bc65047 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -862,9 +862,12 @@ tcp_plugin_disconnect_session (void *cls,
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
(NULL != pm->transmit_cont)
- ? "Could not deliver message to `%4s'.\n"
- : "Could not deliver message to `%4s', notifying.\n",
- GNUNET_i2s (&session->target));
+ ? "Could not deliver message to `%s' at %s.\n"
+ : "Could not deliver message to `%s' at %s, notifying.\n",
+ GNUNET_i2s (&session->target),
+ tcp_plugin_address_to_string (session->plugin,
+ session->address->address,
+ session->address->address_length));
GNUNET_STATISTICS_update (session->plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
-(int64_t) pm->message_size, GNUNET_NO);
@@ -1003,8 +1006,11 @@ create_session (struct Plugin *plugin,
GNUNET_assert (NULL == client);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating new session for peer `%4s'\n",
- GNUNET_i2s (&address->peer));
+ "Creating new session for peer `%4s' at address %s\n",
+ GNUNET_i2s (&address->peer),
+ tcp_plugin_address_to_string (plugin,
+ address->address,
+ address->address_length));
session = GNUNET_new (struct Session);
session->last_activity = GNUNET_TIME_absolute_get ();
session->plugin = plugin;
@@ -1174,9 +1180,10 @@ do_transmit (void *cls, size_t size, void *buf)
session->bytes_in_queue -= pos->message_size;
GNUNET_assert(size >= pos->message_size);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting message of type %u size %u to %s\n",
+ "Transmitting message of type %u size %u to peer %s at %s\n",
ntohs (((struct GNUNET_MessageHeader *) pos->msg)->type),
pos->message_size,
+ GNUNET_i2s (&session->target),
tcp_plugin_address_to_string (session->plugin,
session->address->address,
session->address->address_length));
@@ -1215,9 +1222,6 @@ do_transmit (void *cls, size_t size, void *buf)
}
GNUNET_assert (NULL == hd);
GNUNET_assert (NULL == tl);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Transmitting %u bytes\n",
- ret);
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes currently in TCP buffers"),
- (int64_t) ret,
@@ -1767,13 +1771,6 @@ tcp_plugin_get_session (void *cls,
&session->target,
session,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating new session for `%s' address `%s' session %p\n",
- GNUNET_i2s (&address->peer),
- tcp_plugin_address_to_string (plugin,
- address->address,
- address->address_length),
- session);
/* Send TCP Welcome */
process_pending_messages (session);