[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] branch master updated: preserve invariants while c
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] branch master updated: preserve invariants while calling GCP_detatch_path while reorging paths |
Date: |
Wed, 01 Feb 2017 20:49:55 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 9ebc9fc29 preserve invariants while calling GCP_detatch_path while
reorging paths
9ebc9fc29 is described below
commit 9ebc9fc29aa2626359cc88679baee38f2e31e4de
Author: Christian Grothoff <address@hidden>
AuthorDate: Wed Feb 1 20:49:52 2017 +0100
preserve invariants while calling GCP_detatch_path while reorging paths
---
src/cadet/gnunet-service-cadet-new_paths.c | 31 +++++++++++++++++-------------
src/cadet/gnunet-service-cadet-new_peer.c | 3 ++-
2 files changed, 20 insertions(+), 14 deletions(-)
diff --git a/src/cadet/gnunet-service-cadet-new_paths.c
b/src/cadet/gnunet-service-cadet-new_paths.c
index e2d8da687..14e7b75d5 100644
--- a/src/cadet/gnunet-service-cadet-new_paths.c
+++ b/src/cadet/gnunet-service-cadet-new_paths.c
@@ -233,6 +233,7 @@ GCPP_release (struct CadetPeerPath *path)
GCPP_2s (path));
path->hn = NULL;
entry = path->entries[path->entries_length - 1];
+ GNUNET_assert (path == entry->path);
while (1)
{
/* cut 'off' end of path */
@@ -247,6 +248,7 @@ GCPP_release (struct CadetPeerPath *path)
/* see if new peer at the end likes this path any better */
entry = path->entries[path->entries_length - 1];
+ GNUNET_assert (path == entry->path);
path->hn = GCP_attach_path (entry->peer,
path,
path->entries_length - 1,
@@ -386,7 +388,6 @@ extend_path (struct CadetPeerPath *path,
int force)
{
unsigned int old_len = path->entries_length;
- struct GNUNET_CONTAINER_HeapNode *hn;
int i;
/* Expand path */
@@ -412,18 +413,21 @@ extend_path (struct CadetPeerPath *path,
/* If we extend an existing path, detach it from the
old owner and re-attach to the new one */
- hn = NULL;
+ GCP_detach_path (path->entries[old_len-1]->peer,
+ path,
+ path->hn);
+ path->hn = NULL;
for (i=num_peers-1;i>=0;i--)
{
struct CadetPeerPathEntry *entry = path->entries[old_len + i];
path->entries_length = old_len + i + 1;
recalculate_path_desirability (path);
- hn = GCP_attach_path (peers[i],
- path,
- old_len + (unsigned int) i,
- GNUNET_YES);
- if (NULL != hn)
+ path->hn = GCP_attach_path (peers[i],
+ path,
+ old_len + (unsigned int) i,
+ GNUNET_NO);
+ if (NULL != path->hn)
break;
GCP_path_entry_remove (entry->peer,
entry,
@@ -431,19 +435,20 @@ extend_path (struct CadetPeerPath *path,
GNUNET_free (entry);
path->entries[old_len + i] = NULL;
}
- if (NULL == hn)
+ if (NULL == path->hn)
{
/* none of the peers is interested in this path;
- shrink path back */
+ shrink path back and re-attach. */
GNUNET_array_grow (path->entries,
path->entries_length,
old_len);
+ path->hn = GCP_attach_path (path->entries[old_len - 1]->peer,
+ path,
+ old_len - 1,
+ GNUNET_YES);
+ GNUNET_assert (NULL != path->hn);
return;
}
- GCP_detach_path (path->entries[old_len-1]->peer,
- path,
- path->hn);
- path->hn = hn;
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Extended path %s\n",
GCPP_2s (path));
diff --git a/src/cadet/gnunet-service-cadet-new_peer.c
b/src/cadet/gnunet-service-cadet-new_peer.c
index 070a0ac15..136ab8297 100644
--- a/src/cadet/gnunet-service-cadet-new_peer.c
+++ b/src/cadet/gnunet-service-cadet-new_peer.c
@@ -913,6 +913,7 @@ GCP_attach_path (struct CadetPeer *cp,
GNUNET_CONTAINER_HeapCostType root_desirability;
struct GNUNET_CONTAINER_HeapNode *hn;
+ GNUNET_assert (off == GCPP_get_length (path) - 1);
GNUNET_assert (cp == GCPP_get_peer_at_offset (path,
off));
if (NULL == cp->path_heap)
@@ -972,7 +973,7 @@ GCP_attach_path (struct CadetPeer *cp,
GCPP_get_length (root) - 1)) )
{
/* Got plenty of paths to this destination, and this is a low-quality
- one that we don't care, allow it to die. */
+ one that we don't care about. Allow it to die. */
GNUNET_assert (root ==
GNUNET_CONTAINER_heap_remove_root (cp->path_heap));
GCPP_release (root);
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet] branch master updated: preserve invariants while calling GCP_detatch_path while reorging paths,
gnunet <=