[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16703 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16703 - gnunet/src/ats |
Date: |
Mon, 5 Sep 2011 16:33:46 +0200 |
Author: wachs
Date: 2011-09-05 16:33:46 +0200 (Mon, 05 Sep 2011)
New Revision: 16703
Modified:
gnunet/src/ats/ats_api.c
Log:
fixing issue with unix domain sockets:
updating sessions with plugins not using sessions failed
if (session == NULL) addresses where just overwritten
Modified: gnunet/src/ats/ats_api.c
===================================================================
--- gnunet/src/ats/ats_api.c 2011-09-05 14:23:29 UTC (rev 16702)
+++ gnunet/src/ats/ats_api.c 2011-09-05 14:33:46 UTC (rev 16703)
@@ -288,6 +288,11 @@
struct GNUNET_ATS_SuggestionContext *asc = cls;
struct AllocationRecord *ar = value;
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Suggesting address for peer `%s'\n", GNUNET_h2s (key));
+#endif
+
/* trivial strategy: pick first available address... */
asc->cb (asc->cb_cls, &asc->target, ar->plugin_name, ar->plugin_addr,
ar->plugin_addr_len, ar->session,
@@ -297,6 +302,13 @@
return GNUNET_NO;
}
+int
+map_it (void *cls, const GNUNET_HashCode * key, void *value)
+{
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "Found entry for %s\n",
+ GNUNET_h2s (key));
+ return GNUNET_YES;
+}
/**
* We would like to establish a new connection with a peer.
@@ -315,13 +327,29 @@
{
struct GNUNET_ATS_SuggestionContext *asc;
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Looking up suggested address for peer `%s'\n",
+ GNUNET_i2s (peer));
+#endif
+ int count = 0;
+
asc = GNUNET_malloc (sizeof (struct GNUNET_ATS_SuggestionContext));
asc->cb = cb;
asc->cb_cls = cb_cls;
asc->atc = atc;
asc->target = *peer;
- GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers, &peer->hashPubKey,
- &suggest_address, asc);
+ count =
+ GNUNET_CONTAINER_multihashmap_get_multiple (atc->peers,
&peer->hashPubKey,
+ &suggest_address, asc);
+
+#if DEBUG_ATS
+ GNUNET_CONTAINER_multihashmap_iterate (atc->peers, &map_it, (void *) peer);
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Addresses %u (of %i) processed, \n", count,
+ GNUNET_CONTAINER_multihashmap_size (atc->peers));
+#endif
+
if (NULL == asc->cb)
{
GNUNET_free (asc);
@@ -364,6 +392,9 @@
{
struct GNUNET_ATS_Handle *atc;
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "ATS init\n");
+#endif
atc = GNUNET_malloc (sizeof (struct GNUNET_ATS_Handle));
atc->cfg = cfg;
atc->alloc_cb = alloc_cb;
@@ -404,6 +435,9 @@
void
GNUNET_ATS_shutdown (struct GNUNET_ATS_Handle *atc)
{
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api", "ATS shutdown\n");
+#endif
if (GNUNET_SCHEDULER_NO_TASK != atc->ba_task)
{
GNUNET_SCHEDULER_cancel (atc->ba_task);
@@ -453,9 +487,16 @@
struct AllocationRecord *arold = value;
int change;
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Updating session for peer `%s' plugin `%s'\n",
+ GNUNET_h2s (key), arold->plugin_name, arnew->session,
+ arold->session);
+#endif
+
if (0 != strcmp (arnew->plugin_name, arold->plugin_name))
return GNUNET_YES;
- if ((arnew->session == arold->session) ||
+ if (((arnew->session == arold->session) && (arnew->session != NULL)) ||
((arold->session == NULL) &&
(arold->plugin_addr_len == arnew->plugin_addr_len) &&
(0 ==
@@ -724,6 +765,13 @@
struct AllocationRecord *ar;
struct UpdateSessionContext usc;
+
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Updating address for peer `%s', plugin `%s'\n",
+ GNUNET_i2s (peer), plugin_name);
+#endif
+
ar = create_allocation_record (plugin_name, session, plugin_addr,
plugin_addr_len, ats, ats_count);
usc.atc = atc;
@@ -734,7 +782,11 @@
destroy_allocation_record (NULL, &peer->hashPubKey, ar);
return;
}
-
+#if DEBUG_ATS
+ GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "ats-api",
+ "Adding new address for peer `%s', plugin `%s'\n",
+ GNUNET_i2s (peer), plugin_name);
+#endif
GNUNET_assert (GNUNET_OK ==
GNUNET_CONTAINER_multihashmap_put (atc->peers,
&peer->hashPubKey, ar,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16703 - gnunet/src/ats,
gnunet <=