[vis] Remove duplicate routes from vis output

Message ID dd8d36130907150659v74773aw1fd1060c43ab337b@mail.gmail.com (mailing list archive)
State Superseded, archived
Headers

Commit Message

Edwe Cowley July 15, 2009, 1:59 p.m. UTC
  Revision 1271 introduced a bug on the call to hash->compare() that
caused duplicate routes to appear in the output.  Inverted the
conditional and now it works.

Signed-off-by: Edwe Cowley <edwecowley@gmail.com>
return hash_remove_bucket(hash, &hash_it_t);
}
  

Comments

Marek Lindner July 15, 2009, 5:21 p.m. UTC | #1
On Wednesday 15 July 2009 21:59:32 Edwe Cowley wrote:
> Revision 1271 introduced a bug on the call to hash->compare() that
> caused duplicate routes to appear in the output.  Inverted the
> conditional and now it works.

Thanks for informing us about this bug and proposing a solution. This is a bit 
tricky since batman and the vis server share the same hash implementation 
code. If we apply your patch we will move the bugs to batman. As you correctly 
pointed out the bug was introduced with 1271 because the vis hash->compare() 
callback function was not adapted. Please consider my following patch and let 
me know if it works for you.

Regards,
Marek
  
Edwe Cowley July 16, 2009, 6:57 a.m. UTC | #2
The vis server seems to work perfectly after applying your proposed
patch. Thank you.

Regards

Edwe

On Wed, Jul 15, 2009 at 7:21 PM, Marek Lindner<lindner_marek@yahoo.de> wrote:
> On Wednesday 15 July 2009 21:59:32 Edwe Cowley wrote:
>> Revision 1271 introduced a bug on the call to hash->compare() that
>> caused duplicate routes to appear in the output.  Inverted the
>> conditional and now it works.
>
> Thanks for informing us about this bug and proposing a solution. This is a bit
> tricky since batman and the vis server share the same hash implementation
> code. If we apply your patch we will move the bugs to batman. As you correctly
> pointed out the bug was introduced with 1271 because the vis hash->compare()
> callback function was not adapted. Please consider my following patch and let
> me know if it works for you.
>
> Regards,
> Marek
>
> _______________________________________________
> B.A.T.M.A.N mailing list
> B.A.T.M.A.N@lists.open-mesh.net
> https://lists.open-mesh.net/mm/listinfo/b.a.t.m.a.n
>
  
Marek Lindner July 16, 2009, 10:42 a.m. UTC | #3
On Thursday 16 July 2009 14:57:28 Edwe Cowley wrote:
> The vis server seems to work perfectly after applying your proposed
> patch. Thank you.

Ok, it is in the repos now.

Regards,
Marek
  

Patch

Index: batman/hash.c
===================================================================
--- batman/hash.c (revision 1343)
+++ batman/hash.c (working copy)
@@ -179,7 +179,7 @@ 
bucket = hash->table[index];

while (bucket != NULL) {
- if (hash->compare(bucket->data, data))
+ if (!(hash->compare(bucket->data, data)))
return -1;

prev_bucket = bucket;
@@ -217,7 +217,7 @@ 
bucket = hash->table[index];

while (bucket != NULL) {
- if (hash->compare(bucket->data, keydata))
+ if (!(hash->compare(bucket->data, keydata)))
return bucket->data;

bucket = bucket->next;
@@ -260,7 +260,7 @@ 
hash_it_t.prev_bucket = NULL;

while (hash_it_t.bucket != NULL) {
- if (hash->compare(hash_it_t.bucket->data, data)) {
+ if (!(hash->compare(hash_it_t.bucket->data, data))) {
hash_it_t.first_bucket = (hash_it_t.bucket ==
hash->table[hash_it_t.index] ? &hash->table[ hash_it_t.index ] :
NULL);