[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r28175 - in gnunet/src: dv set
From: |
gnunet |
Subject: |
[GNUnet-SVN] r28175 - in gnunet/src: dv set |
Date: |
Thu, 18 Jul 2013 23:12:13 +0200 |
Author: grothoff
Date: 2013-07-18 23:12:12 +0200 (Thu, 18 Jul 2013)
New Revision: 28175
Modified:
gnunet/src/dv/dv_api.c
gnunet/src/dv/gnunet-service-dv.c
gnunet/src/dv/plugin_transport_dv.c
gnunet/src/set/gnunet-service-set.c
gnunet/src/set/set_api.c
Log:
-minor code cleanup
Modified: gnunet/src/dv/dv_api.c
===================================================================
--- gnunet/src/dv/dv_api.c 2013-07-18 16:52:05 UTC (rev 28174)
+++ gnunet/src/dv/dv_api.c 2013-07-18 21:12:12 UTC (rev 28175)
@@ -516,7 +516,7 @@
{
struct GNUNET_DV_ServiceHandle *sh;
- sh = GNUNET_malloc (sizeof (struct GNUNET_DV_ServiceHandle));
+ sh = GNUNET_new (struct GNUNET_DV_ServiceHandle);
sh->cfg = cfg;
sh->cls = cls;
sh->connect_cb = connect_cb;
Modified: gnunet/src/dv/gnunet-service-dv.c
===================================================================
--- gnunet/src/dv/gnunet-service-dv.c 2013-07-18 16:52:05 UTC (rev 28174)
+++ gnunet/src/dv/gnunet-service-dv.c 2013-07-18 21:12:12 UTC (rev 28175)
@@ -769,8 +769,10 @@
if (DEFAULT_FISHEYE_DEPTH - 1 == neighbor->consensus_insertion_distance)
{
/* we have added all elements to the set, run the operation */
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Finished building my SET, committing\n");
GNUNET_SET_commit (neighbor->set_op,
- neighbor->my_set);
+ neighbor->my_set);
GNUNET_SET_destroy (neighbor->my_set);
neighbor->my_set = NULL;
return;
@@ -783,6 +785,8 @@
(consensi[neighbor->consensus_insertion_distance].array_length <
neighbor->consensus_insertion_offset) &&
(NULL ==
consensi[neighbor->consensus_insertion_distance].targets[neighbor->consensus_insertion_offset])
)
neighbor->consensus_insertion_offset++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Adding element to SET\n");
GNUNET_SET_add_element (neighbor->my_set,
&element,
&build_set, neighbor);
@@ -801,6 +805,9 @@
struct Route *route;
struct GNUNET_HashCode session_id;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Direct connection to %s established, routing table exchange
begins.\n",
+ GNUNET_i2s (&neighbor->peer));
GNUNET_STATISTICS_update (stats,
"# peers connected (1-hop)",
1, GNUNET_NO);
@@ -823,15 +830,21 @@
&session_id, sizeof (session_id),
NULL, 0);
if (1 == GNUNET_CRYPTO_hash_cmp (&neighbor->peer.hashPubKey,
- &my_identity.hashPubKey))
+ &my_identity.hashPubKey))
+ {
neighbor->initiate_task = GNUNET_SCHEDULER_add_now (&initiate_set_union,
- neighbor);
+ neighbor);
+ }
else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Starting SET listen operation\n");
neighbor->listen_handle = GNUNET_SET_listen (cfg,
GNUNET_SET_OPERATION_UNION,
&neighbor->real_session_id,
&listen_set_union,
neighbor);
+ }
}
@@ -842,7 +855,8 @@
* @param peer peer identity this notification is about
*/
static void
-handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+handle_core_connect (void *cls,
+ const struct GNUNET_PeerIdentity *peer)
{
struct DirectNeighbor *neighbor;
@@ -868,7 +882,7 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Core connected to %s (distance unknown)\n",
GNUNET_i2s (peer));
- neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
+ neighbor = GNUNET_new (struct DirectNeighbor);
neighbor->peer = *peer;
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
@@ -909,14 +923,16 @@
* @return GNUNET_YES to continue iteration, GNUNET_NO to stop
*/
static int
-check_possible_route (void *cls, const struct GNUNET_HashCode * key, void
*value)
+check_possible_route (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Target *target = value;
struct Route *route;
route = GNUNET_CONTAINER_multihashmap_get (all_routes,
- key);
+ key);
if (NULL != route)
{
if (ntohl (route->target.distance) > ntohl (target->distance) + 1)
@@ -928,7 +944,7 @@
}
return GNUNET_YES; /* got a route to this target already */
}
- route = GNUNET_malloc (sizeof (struct Route));
+ route = GNUNET_new (struct Route);
route->next_hop = neighbor;
route->target.distance = htonl (ntohl (target->distance) + 1);
route->target.peer = target->peer;
@@ -953,7 +969,9 @@
* @return GNUNET_YES to continue iteration
*/
static int
-refresh_routes (void *cls, const struct GNUNET_HashCode * key, void *value)
+refresh_routes (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = value;
@@ -1000,7 +1018,9 @@
* @return GNUNET_YES to continue iteration, GNUNET_NO to stop
*/
static int
-cull_routes (void *cls, const struct GNUNET_HashCode * key, void *value)
+cull_routes (void *cls,
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Route *route = value;
@@ -1133,7 +1153,7 @@
handle_direct_connect (neighbor);
return;
}
- neighbor = GNUNET_malloc (sizeof (struct DirectNeighbor));
+ neighbor = GNUNET_new (struct DirectNeighbor);
neighbor->peer = address->peer;
GNUNET_assert (GNUNET_YES ==
GNUNET_CONTAINER_multihashmap_put (direct_neighbors,
@@ -1201,8 +1221,8 @@
*/
static int
check_target_added (void *cls,
- const struct GNUNET_HashCode *key,
- void *value)
+ const struct GNUNET_HashCode *key,
+ void *value)
{
struct DirectNeighbor *neighbor = cls;
struct Target *target = value;
@@ -1244,7 +1264,7 @@
"Discovered new route to %s using %u hops\n",
GNUNET_i2s (&target->peer),
(unsigned int) (ntohl (target->distance) + 1));
- current_route = GNUNET_malloc (sizeof (struct Route));
+ current_route = GNUNET_new (struct Route);
current_route->next_hop = neighbor;
current_route->target.peer = target->peer;
current_route->target.distance = htonl (ntohl (target->distance) + 1);
@@ -1277,6 +1297,9 @@
struct DirectNeighbor *neighbor = cls;
struct Target *target;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Got SET union result: %d\n",
+ status);
switch (status)
{
case GNUNET_SET_STATUS_OK:
@@ -1285,7 +1308,7 @@
GNUNET_break_op (0);
return;
}
- target = GNUNET_malloc (sizeof (struct Target));
+ target = GNUNET_new (struct Target);
memcpy (target, element->data, sizeof (struct Target));
if (GNUNET_YES !=
GNUNET_CONTAINER_multihashmap_put (neighbor->neighbor_table_consensus,
@@ -1422,6 +1445,8 @@
{
struct DirectNeighbor *neighbor = cls;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Initiating SET union\n");
neighbor->initiate_task = GNUNET_SCHEDULER_NO_TASK;
neighbor->my_set = GNUNET_SET_create (cfg,
GNUNET_SET_OPERATION_UNION);
@@ -1455,6 +1480,8 @@
const struct GNUNET_MessageHeader *payload;
struct Route *route;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Handling DV message\n");
if (ntohs (message->size) < sizeof (struct RouteMessage) + sizeof (struct
GNUNET_MessageHeader))
{
GNUNET_break_op (0);
@@ -1506,6 +1533,9 @@
1, GNUNET_NO);
return GNUNET_OK;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Forwarding message to %s\n",
+ GNUNET_i2s (&rm->target));
forward_payload (route->next_hop,
ntohl (route->target.distance),
0,
Modified: gnunet/src/dv/plugin_transport_dv.c
===================================================================
--- gnunet/src/dv/plugin_transport_dv.c 2013-07-18 16:52:05 UTC (rev 28174)
+++ gnunet/src/dv/plugin_transport_dv.c 2013-07-18 21:12:12 UTC (rev 28175)
@@ -38,6 +38,9 @@
#include "dv.h"
+#define LOG(kind,...) GNUNET_log_from (kind, "transport-dv",__VA_ARGS__)
+
+
/**
* Encapsulation of all of the state of the plugin.
*/
@@ -287,7 +290,7 @@
notify_distance_change (session);
return; /* nothing to do */
}
- session = GNUNET_malloc (sizeof (struct Session));
+ session = GNUNET_new (struct Session);
session->sender = *peer;
session->distance = distance;
GNUNET_assert (GNUNET_YES ==
@@ -451,7 +454,7 @@
memcpy (&box[1], msgbuf, msgbuf_size);
msg = box;
}
- pr = GNUNET_malloc (sizeof (struct PendingRequest));
+ pr = GNUNET_new (struct PendingRequest);
pr->transmit_cont = cont;
pr->transmit_cont_cls = cont_cls;
pr->session = session;
@@ -656,6 +659,9 @@
/**
* Entry point for the plugin.
+ *
+ * @param cls closure with the plugin environment
+ * @return plugin API
*/
void *
libgnunet_plugin_transport_dv_init (void *cls)
@@ -664,7 +670,7 @@
struct GNUNET_TRANSPORT_PluginFunctions *api;
struct Plugin *plugin;
- plugin = GNUNET_malloc (sizeof (struct Plugin));
+ plugin = GNUNET_new (struct Plugin);
plugin->env = env;
plugin->sessions = GNUNET_CONTAINER_multihashmap_create (1024 * 8,
GNUNET_YES);
plugin->mst = GNUNET_SERVER_mst_create (&unbox_cb,
@@ -682,7 +688,7 @@
GNUNET_free (plugin);
return NULL;
}
- api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions));
+ api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions);
api->cls = plugin;
api->send = &dv_plugin_send;
api->disconnect = &dv_plugin_disconnect;
@@ -718,6 +724,9 @@
/**
* Exit point from the plugin.
+ *
+ * @param cls plugin API
+ * @return NULL
*/
void *
libgnunet_plugin_transport_dv_done (void *cls)
Modified: gnunet/src/set/gnunet-service-set.c
===================================================================
--- gnunet/src/set/gnunet-service-set.c 2013-07-18 16:52:05 UTC (rev 28174)
+++ gnunet/src/set/gnunet-service-set.c 2013-07-18 21:12:12 UTC (rev 28175)
@@ -561,8 +561,9 @@
const struct GNUNET_MessageHeader *m)
{
struct Incoming *incoming;
- struct GNUNET_SET_AcceptRejectMessage *msg = (struct
GNUNET_SET_AcceptRejectMessage *) m;
+ const struct GNUNET_SET_AcceptRejectMessage *msg;
+ msg = (const struct GNUNET_SET_AcceptRejectMessage *) m;
GNUNET_break (0 == ntohl (msg->request_id));
incoming = get_incoming (ntohl (msg->accept_reject_id));
@@ -603,7 +604,8 @@
}
msg = (const struct GNUNET_SET_ElementMessage *) m;
el.size = ntohs (m->size) - sizeof *msg;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "client ins/rem element of size %u\n",
el.size);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "client ins/rem element of size %u\n", el.size);
el.data = &msg[1];
if (GNUNET_MESSAGE_TYPE_SET_REMOVE == ntohs (m->type))
set->vt->remove (set->state, &el);
Modified: gnunet/src/set/set_api.c
===================================================================
--- gnunet/src/set/set_api.c 2013-07-18 16:52:05 UTC (rev 28174)
+++ gnunet/src/set/set_api.c 2013-07-18 21:12:12 UTC (rev 28175)
@@ -157,12 +157,13 @@
static void
handle_result (void *cls, const struct GNUNET_MessageHeader *mh)
{
- struct GNUNET_SET_ResultMessage *msg = (struct GNUNET_SET_ResultMessage *)
mh;
+ const struct GNUNET_SET_ResultMessage *msg;
struct GNUNET_SET_Handle *set = cls;
struct GNUNET_SET_OperationHandle *oh;
struct GNUNET_SET_Element e;
enum GNUNET_SET_Status result_status;
+ msg = (const struct GNUNET_SET_ResultMessage *) mh;
GNUNET_assert (NULL != set);
GNUNET_assert (NULL != set->mq);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r28175 - in gnunet/src: dv set,
gnunet <=