[haiku-commits] haiku: hrev48648 - in src/add-ons/kernel: network/datalink_protocols/arp file_cache

  • From: pulkomandy@xxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 10 Jan 2015 10:48:08 +0100 (CET)

hrev48648 adds 2 changesets to branch 'master'
old head: 740112693b62765574866f9bd431720edd69986b
new head: d1644d7e4fdc62dd671d792278f744d476a110df
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=d1644d7+%5E7401126

----------------------------------------------------------------------------

42eb787: rule_based_prefetcher: actually implement hashing
  
  This file is apparently not part of the image so I don't know how to
  test these changes.

d1644d7: Fix another misuse of BOpenHashTable::Iterator
  
  * This ioctl is used only in the arp command, but still we should keep
  it working
  * Similar to the problem in elf.cpp, this relied on entry being set to
  NULL when trying to iterate after the last element.

                                 [ Adrien Destugues <pulkomandy@xxxxxxxxx> ]

----------------------------------------------------------------------------

2 files changed, 7 insertions(+), 7 deletions(-)
src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp   | 6 ++++--
src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp | 8 +++-----

############################################################################

Commit:      42eb787c74a09f47cc2e4e551219730658dc24b6
URL:         http://cgit.haiku-os.org/haiku/commit/?id=42eb787
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Fri Jan  9 22:14:41 2015 UTC

rule_based_prefetcher: actually implement hashing

This file is apparently not part of the image so I don't know how to
test these changes.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp 
b/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp
index 5a7523e..0f4525b 100644
--- a/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp
+++ b/src/add-ons/kernel/file_cache/rule_based_prefetcher.cpp
@@ -148,18 +148,19 @@ class RuleMatcher {
                team_rules      *fRules;
 };
 
+
 struct RuleHash {
                typedef char*           KeyType;
                typedef rules           ValueType;
 
                size_t HashKey(KeyType key) const
                {
-                       return key >> 1;
+                       return hash_hash_string(key);
                }
 
                size_t Hash(ValueType* value) const
                {
-                       return HashKey(value->bar);
+                       return HashKey(value->name);
                }
 
                bool Compare(KeyType key, ValueType* rules) const
@@ -173,6 +174,7 @@ struct RuleHash {
                }
 };
 
+
 struct TeamHash {
                typedef team_id         KeyType;
                typedef team_rules      ValueType;

############################################################################

Revision:    hrev48648
Commit:      d1644d7e4fdc62dd671d792278f744d476a110df
URL:         http://cgit.haiku-os.org/haiku/commit/?id=d1644d7
Author:      Adrien Destugues <pulkomandy@xxxxxxxxx>
Date:        Sat Jan 10 09:46:32 2015 UTC

Fix another misuse of BOpenHashTable::Iterator

* This ioctl is used only in the arp command, but still we should keep
it working
* Similar to the problem in elf.cpp, this relied on entry being set to
NULL when trying to iterate after the last element.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp 
b/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp
index fac074f..fe58de1 100644
--- a/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp
+++ b/src/add-ons/kernel/network/datalink_protocols/arp/arp.cpp
@@ -885,14 +885,12 @@ arp_control(const char *subsystem, uint32 function, void 
*buffer,
 
                        arp_entry *entry = NULL;
                        uint32 i = 0;
-                       while (iterator.HasNext() && i < control.cookie) {
+                       for (uint32 i = 0; i <= control.cookie; i++) {
+                               if (!iterator.HasNext())
+                                       return B_ENTRY_NOT_FOUND;
                                entry = iterator.Next();
-                               i++;
                        }
 
-                       if (entry == NULL)
-                               return B_ENTRY_NOT_FOUND;
-
                        control.cookie++;
                        control.address = entry->protocol_address;
                        if (entry->hardware_address.sdl_alen == 
ETHER_ADDRESS_LENGTH) {


Other related posts: