[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r27743 - gnunet/src/ats
From: |
gnunet |
Subject: |
[GNUnet-SVN] r27743 - gnunet/src/ats |
Date: |
Thu, 4 Jul 2013 14:29:29 +0200 |
Author: wachs
Date: 2013-07-04 14:29:29 +0200 (Thu, 04 Jul 2013)
New Revision: 27743
Modified:
gnunet/src/ats/gnunet-service-ats_addresses.c
Log:
correct order of address deletion:
remove, notify, free
Modified: gnunet/src/ats/gnunet-service-ats_addresses.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_addresses.c 2013-07-04 12:29:01 UTC
(rev 27742)
+++ gnunet/src/ats/gnunet-service-ats_addresses.c 2013-07-04 12:29:29 UTC
(rev 27743)
@@ -551,28 +551,6 @@
}
-/**
- * Destroy the given address.
- *
- * @param handle the address handle
- * @param addr address to destroy
- * @return GNUNET_YES if bandwidth allocations should be recalcualted
- */
-static int
-destroy_address (struct GAS_Addresses_Handle *handle, struct ATS_Address *addr)
-{
- int ret;
-
- ret = GNUNET_NO;
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CONTAINER_multihashmap_remove (handle->addresses,
- &addr->peer.hashPubKey,
- addr));
- free_address (addr);
- return ret;
-}
-
-
struct CompareAddressContext
{
const struct ATS_Address *search;
@@ -1008,13 +986,16 @@
(0 == memcmp (des->addr, aa->addr, aa->addr_len)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Deleting full address for peer `%s' session %u %p\n",
GNUNET_i2s (&aa->peer), aa->session_id, aa);
/* Notify solver about deletion */
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (handle->addresses,
+ &aa->peer.hashPubKey, aa));
handle->s_del (handle->solver, aa, GNUNET_NO);
- destroy_address (handle, aa);
+ free_address (aa);
dc->result = GNUNET_NO;
return GNUNET_OK; /* Continue iteration */
}
@@ -1028,7 +1009,7 @@
if ((aa->session_id != 0) &&
(0 != strcmp (des->plugin, aa->plugin)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Different plugins during removal: `%s' vs `%s' \n",
des->plugin, aa->plugin);
GNUNET_break (0);
@@ -1043,8 +1024,11 @@
GNUNET_i2s (&aa->peer), aa->plugin, aa->session_id);
/* Notify solver about deletion */
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multihashmap_remove (handle->addresses,
+ &aa->peer.hashPubKey, aa));
handle->s_del (handle->solver, aa, GNUNET_NO);
- destroy_address (handle, aa);
+ free_address (aa);
dc->result = GNUNET_NO;
return GNUNET_OK; /* Continue iteration */
}
@@ -1084,19 +1068,12 @@
{
struct ATS_Address *ea;
struct DestroyContext dc;
-
if (GNUNET_NO == handle->running)
return;
/* Get existing address */
ea = lookup_address (handle, peer, plugin_name, plugin_addr, plugin_addr_len,
session_id, NULL, 0);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received `%s' for peer `%s' address %p session %u\n",
- "ADDRESS DESTROY",
- GNUNET_i2s (peer), ea, session_id);
-
if (ea == NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Tried to destroy unknown address
for peer `%s' `%s' session id %u\n",
@@ -1104,6 +1081,11 @@
return;
}
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Received `%s' for peer `%s' address %p session %u\n",
+ "ADDRESS DESTROY",
+ GNUNET_i2s (peer), ea, session_id);
+
GNUNET_break (0 < strlen (plugin_name));
dc.handle = handle;
dc.aa = create_address (peer, plugin_name, plugin_addr, plugin_addr_len,
session_id);
@@ -1740,7 +1722,7 @@
/**
- * Free memory of address.
+ * Destroy all addresses iterator
*
* @param cls NULL
* @param key peer identity (unused)
@@ -1748,12 +1730,18 @@
* @return GNUNET_OK (continue to iterate)
*/
static int
-free_address_it (void *cls, const struct GNUNET_HashCode * key, void *value)
+destroy_all_address_it (void *cls, const struct GNUNET_HashCode * key, void
*value)
{
struct GAS_Addresses_Handle *handle = cls;
struct ATS_Address *aa = value;
+
+ /* Remove */
+ GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove
(handle->addresses, key, value));
+ /* Notify */
handle->s_del (handle->solver, aa, GNUNET_NO);
- destroy_address (handle, aa);
+ /* Destroy */
+ free_address (aa);
+
return GNUNET_OK;
}
@@ -1772,9 +1760,8 @@
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s'\n",
"DESTROY ALL");
-
if (handle->addresses != NULL)
- GNUNET_CONTAINER_multihashmap_iterate (handle->addresses,
&free_address_it, handle);
+ GNUNET_CONTAINER_multihashmap_iterate (handle->addresses,
&destroy_all_address_it, handle);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r27743 - gnunet/src/ats,
gnunet <=