* @brief Information we track per path.
* @author Bartlomiej Polot
* @author Christian Grothoff
- *
- * TODO:
- * - path desirability score calculations are not done
*/
#include "platform.h"
#include "gnunet-service-cadet-new_connection.h"
+#include "gnunet-service-cadet-new_tunnels.h"
#include "gnunet-service-cadet-new_peer.h"
#include "gnunet-service-cadet-new_paths.h"
static void
recalculate_path_desirability (struct CadetPeerPath *path)
{
- /* FIXME: update path desirability! */
- GNUNET_break (0); // not implemented
+ double result = 0.0;
+
+ for (unsigned int i=0;i<path->entries_length;i++)
+ {
+ struct CadetPeer *cp = path->entries[i]->peer;
+
+ result += GCP_get_desirability_of_path (cp,
+ i);
+ }
+ path->desirability = (GNUNET_CONTAINER_HeapCostType) result;
}
"Destroying path %s\n",
GCPP_2s (path));
for (unsigned int i=0;i<path->entries_length;i++)
- GNUNET_free (path->entries[i]);
+ {
+ struct CadetPeerPathEntry *entry = path->entries[i];
+
+ if (NULL != entry->cc)
+ {
+ struct CadetTConnection *ct;
+
+ ct = GCC_get_ct (entry->cc);
+ if (NULL != ct)
+ GCT_connection_lost (ct);
+ GCC_destroy_without_tunnel (entry->cc);
+ }
+ GNUNET_free (entry);
+ }
GNUNET_free (path->entries);
GNUNET_free (path);
}