[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33730 - in gnunet/src: cadet include
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33730 - in gnunet/src: cadet include |
Date: |
Wed, 18 Jun 2014 02:22:35 +0200 |
Author: bartpolot
Date: 2014-06-18 02:22:35 +0200 (Wed, 18 Jun 2014)
New Revision: 33730
Modified:
gnunet/src/cadet/cadet_api.c
gnunet/src/cadet/cadet_common.c
gnunet/src/cadet/gnunet-cadet.c
gnunet/src/cadet/gnunet-service-cadet_local.c
gnunet/src/include/gnunet_cadet_service.h
gnunet/src/include/gnunet_protocols.h
Log:
Add a debug "dump to stderr" feature to cadet
Modified: gnunet/src/cadet/cadet_api.c
===================================================================
--- gnunet/src/cadet/cadet_api.c 2014-06-17 20:40:23 UTC (rev 33729)
+++ gnunet/src/cadet/cadet_api.c 2014-06-18 00:22:35 UTC (rev 33730)
@@ -1810,6 +1810,21 @@
/**
+ * Request a debug dump on the service's STDERR.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h cadet handle
+ */
+void
+GNUNET_CADET_request_dump (struct GNUNET_CADET_Handle *h)
+{
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "requesting dump\n");
+ send_info_request (h, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP);
+}
+
+
+/**
* Request information about peers known to the running cadet service.
* The callback will be called for every peer known to the service.
* Only one info request (of any kind) can be active at once.
Modified: gnunet/src/cadet/cadet_common.c
===================================================================
--- gnunet/src/cadet/cadet_common.c 2014-06-17 20:40:23 UTC (rev 33729)
+++ gnunet/src/cadet/cadet_common.c 2014-06-18 00:22:35 UTC (rev 33730)
@@ -328,10 +328,10 @@
break;
/**
- * 640kb should be enough for everybody
+ * Debug request.
*/
- case 299:
- t = "RESERVE_END";
+ case GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP:
+ t = "INFO_DUMP";
break;
default:
Modified: gnunet/src/cadet/gnunet-cadet.c
===================================================================
--- gnunet/src/cadet/gnunet-cadet.c 2014-06-17 20:40:23 UTC (rev 33729)
+++ gnunet/src/cadet/gnunet-cadet.c 2014-06-18 00:22:35 UTC (rev 33730)
@@ -32,7 +32,7 @@
/**
* Option -m.
*/
-static int monitor_connections;
+static int monitor_mode;
/**
* Option -P.
@@ -75,6 +75,11 @@
int echo;
/**
+ * Request a debug dump
+ */
+int dump;
+
+/**
* Time of last echo request.
*/
struct GNUNET_TIME_Absolute echo_time;
@@ -333,7 +338,21 @@
}
+/**
+ * Call CADET's monitor API, request debug dump on the service.
+ *
+ * @param cls Closure (unused).
+ * @param tc TaskContext
+ */
+static void
+request_dump (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_CADET_request_dump (mh);
+ GNUNET_SCHEDULER_cancel (sd);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &shutdown_task,
NULL);
+}
+
/**
* Call CADET's monitor API, get info of one connection.
*
@@ -458,7 +477,7 @@
{
if (NULL == peer)
{
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
@@ -512,7 +531,7 @@
{
if (NULL == peer)
{
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
@@ -560,7 +579,7 @@
FPRINTF (stdout, "- enc state: %u\n", estate);
FPRINTF (stdout, "- con state: %u\n", cstate);
}
- if (GNUNET_YES != monitor_connections)
+ if (GNUNET_YES != monitor_mode)
{
GNUNET_SCHEDULER_shutdown();
}
@@ -706,7 +725,7 @@
target_id = args[0];
target_port = args[0] && args[1] ? atoi(args[1]) : 0;
if ( (0 != (request_peers | request_tunnels)
- || 0 != monitor_connections
+ || 0 != monitor_mode
|| NULL != tunnel_id
|| NULL != conn_id
|| NULL != channel_id)
@@ -718,9 +737,15 @@
return;
}
- if (NULL != target_id)
+ if (GNUNET_YES == dump)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "requesting debug dump\n");
+ GNUNET_SCHEDULER_add_now (&request_dump, NULL);
+ }
+ else if (NULL != target_id)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Creating channel to %s\n",
target_id);
GNUNET_SCHEDULER_add_now (&create_channel, NULL);
@@ -809,6 +834,9 @@
{'e', "echo", NULL,
gettext_noop ("activate echo mode"),
GNUNET_NO, &GNUNET_GETOPT_set_one, &echo},
+ {'d', "dump", NULL,
+ gettext_noop ("dump debug information to STDERR"),
+ GNUNET_NO, &GNUNET_GETOPT_set_one, &dump},
// {'m', "monitor", NULL,
// gettext_noop ("provide information about all events (continuously)"),
// GNUNET_NO, &GNUNET_GETOPT_set_one, &monitor_mode},
@@ -831,7 +859,7 @@
GNUNET_GETOPT_OPTION_END
};
- monitor_connections = GNUNET_NO;
+ monitor_mode = GNUNET_NO;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
Modified: gnunet/src/cadet/gnunet-service-cadet_local.c
===================================================================
--- gnunet/src/cadet/gnunet-service-cadet_local.c 2014-06-17 20:40:23 UTC
(rev 33729)
+++ gnunet/src/cadet/gnunet-service-cadet_local.c 2014-06-18 00:22:35 UTC
(rev 33730)
@@ -580,7 +580,6 @@
}
-
/**
* Iterator over all peers to send a monitoring client info about each peer.
*
@@ -615,6 +614,36 @@
/**
+ * Iterator over all peers to dump info for each peer.
+ *
+ * @param cls Closure (unused).
+ * @param peer Peer ID (tunnel remote peer).
+ * @param value Peer info.
+ *
+ * @return #GNUNET_YES, to keep iterating.
+ */
+static int
+show_peer_iterator (void *cls,
+ const struct GNUNET_PeerIdentity * peer,
+ void *value)
+{
+ struct CadetPeer *p = value;
+ struct CadetTunnel *t;
+
+ LOG (GNUNET_ERROR_TYPE_ERROR, "Peer %s\n", GCP_2s (p));
+ LOG (GNUNET_ERROR_TYPE_ERROR, " %u paths\n", GCP_count_paths (p));
+
+ t = GCP_get_tunnel (p);
+ if (NULL != t)
+ GCT_debug (t, GNUNET_ERROR_TYPE_ERROR);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR, "\n");
+
+ return GNUNET_YES;
+}
+
+
+/**
* Handler for client's INFO PEERS request.
*
* @param cls Closure (unused).
@@ -831,6 +860,42 @@
/**
+ * Handler for client's INFO_DUMP request.
+ *
+ * @param cls Closure (unused).
+ * @param client Identification of the client.
+ * @param message The actual message.
+ */
+void
+handle_info_dump (void *cls, struct GNUNET_SERVER_Client *client,
+ const struct GNUNET_MessageHeader *message)
+{
+ struct CadetClient *c;
+
+ /* Sanity check for client registration */
+ if (NULL == (c = GML_client_get (client)))
+ {
+ GNUNET_break (0);
+ GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+ return;
+ }
+
+ LOG (GNUNET_ERROR_TYPE_INFO, "Received dump info request from client %u\n",
+ c->id);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "*************************** DUMP START ***************************\n");
+
+ GCP_iterate_all (&show_peer_iterator, NULL);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "**************************** DUMP END ****************************\n");
+
+ GNUNET_SERVER_receive_done (client, GNUNET_OK);
+}
+
+
+/**
* Functions to handle messages from clients
*/
static struct GNUNET_SERVER_MessageHandler client_handlers[] = {
@@ -848,6 +913,8 @@
sizeof (struct GNUNET_MessageHeader)},
{&handle_show_tunnel, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_TUNNEL,
sizeof (struct GNUNET_CADET_LocalInfo)},
+ {&handle_info_dump, NULL, GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP,
+ sizeof (struct GNUNET_MessageHeader)},
{NULL, NULL, 0, 0}
};
Modified: gnunet/src/include/gnunet_cadet_service.h
===================================================================
--- gnunet/src/include/gnunet_cadet_service.h 2014-06-17 20:40:23 UTC (rev
33729)
+++ gnunet/src/include/gnunet_cadet_service.h 2014-06-18 00:22:35 UTC (rev
33730)
@@ -493,6 +493,15 @@
GNUNET_CADET_ChannelCB callback,
void *callback_cls);
+/**
+ * Request a debug dump on the service's STDERR.
+ *
+ * WARNING: unstable API, likely to change in the future!
+ *
+ * @param h cadet handle
+ */
+void
+GNUNET_CADET_request_dump (struct GNUNET_CADET_Handle *h);
/**
* Request information about peers known to the running cadet service.
Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h 2014-06-17 20:40:23 UTC (rev
33729)
+++ gnunet/src/include/gnunet_protocols.h 2014-06-18 00:22:35 UTC (rev
33730)
@@ -946,9 +946,9 @@
#define GNUNET_MESSAGE_TYPE_CADET_CLI 298
/**
- * 640kb should be enough for everybody
+ * Debug request.
*/
-#define GNUNET_MESSAGE_TYPE_CADET_RESERVE_END 299
+#define GNUNET_MESSAGE_TYPE_CADET_LOCAL_INFO_DUMP 299
@@ -2493,7 +2493,7 @@
#define GNUNET_MESSAGE_TYPE_SOCIAL_JOIN_DECISION 848
/*******************************************************************************
- * X-VINE DHT messages
+ * X-VINE DHT messages
******************************************************************************/
/**
@@ -2532,17 +2532,17 @@
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_SETUP_REJECTION 886
/**
- * Trail Tear down Message.
+ * Trail Tear down Message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN 887
/**
- * Routing table add message.
+ * Routing table add message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_ADD_TRAIL 888
/**
- * Trail compression message.
+ * Trail compression message.
*/
#define GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_COMPRESSION 889
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33730 - in gnunet/src: cadet include,
gnunet <=