Fix bug when comparing flags. Simplify hash map key. Thanks Ingo!
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39118 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -185,22 +185,18 @@ class NodeMonitorService : public NotificationService {
|
|||||||
|
|
||||||
typedef BOpenHashTable<HashDefinition> MonitorHash;
|
typedef BOpenHashTable<HashDefinition> MonitorHash;
|
||||||
|
|
||||||
struct volume_hash_key {
|
|
||||||
dev_t device;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VolumeHashDefinition {
|
struct VolumeHashDefinition {
|
||||||
typedef volume_hash_key* KeyType;
|
typedef dev_t KeyType;
|
||||||
typedef node_monitor ValueType;
|
typedef node_monitor ValueType;
|
||||||
|
|
||||||
size_t HashKey(volume_hash_key* key) const
|
size_t HashKey(dev_t key) const
|
||||||
{ return _Hash(key->device); }
|
{ return _Hash(key); }
|
||||||
size_t Hash(node_monitor *monitor) const
|
size_t Hash(node_monitor *monitor) const
|
||||||
{ return _Hash(monitor->device); }
|
{ return _Hash(monitor->device); }
|
||||||
|
|
||||||
bool Compare(volume_hash_key* key, node_monitor *monitor) const
|
bool Compare(dev_t key, node_monitor *monitor) const
|
||||||
{
|
{
|
||||||
return key->device == monitor->device;
|
return key == monitor->device;
|
||||||
}
|
}
|
||||||
|
|
||||||
node_monitor*& GetLink(node_monitor* monitor) const
|
node_monitor*& GetLink(node_monitor* monitor) const
|
||||||
@@ -290,7 +286,7 @@ NodeMonitorService::InitCheck()
|
|||||||
void
|
void
|
||||||
NodeMonitorService::_RemoveMonitor(node_monitor *monitor, uint32 flags)
|
NodeMonitorService::_RemoveMonitor(node_monitor *monitor, uint32 flags)
|
||||||
{
|
{
|
||||||
if (flags | B_WATCH_VOLUME)
|
if ((flags & B_WATCH_VOLUME) != 0)
|
||||||
fVolumeMonitors.Remove(monitor);
|
fVolumeMonitors.Remove(monitor);
|
||||||
else
|
else
|
||||||
fMonitors.Remove(monitor);
|
fMonitors.Remove(monitor);
|
||||||
@@ -298,6 +294,7 @@ NodeMonitorService::_RemoveMonitor(node_monitor *monitor, uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//! Helper function for the RemoveListener function.
|
||||||
status_t
|
status_t
|
||||||
NodeMonitorService::_RemoveListener(io_context *context, dev_t device,
|
NodeMonitorService::_RemoveListener(io_context *context, dev_t device,
|
||||||
ino_t node, NotificationListener& notificationListener,
|
ino_t node, NotificationListener& notificationListener,
|
||||||
@@ -359,12 +356,8 @@ NodeMonitorService::_RemoveListener(monitor_listener *listener)
|
|||||||
node_monitor *
|
node_monitor *
|
||||||
NodeMonitorService::_MonitorFor(dev_t device, ino_t node, bool isVolumeListener)
|
NodeMonitorService::_MonitorFor(dev_t device, ino_t node, bool isVolumeListener)
|
||||||
{
|
{
|
||||||
if (isVolumeListener) {
|
if (isVolumeListener)
|
||||||
struct volume_hash_key key;
|
return fVolumeMonitors.Lookup(device);
|
||||||
key.device = device;
|
|
||||||
|
|
||||||
return fVolumeMonitors.Lookup(&key);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct monitor_hash_key key;
|
struct monitor_hash_key key;
|
||||||
key.device = device;
|
key.device = device;
|
||||||
@@ -479,7 +472,7 @@ NodeMonitorService::AddListener(io_context *context, dev_t device, ino_t node,
|
|||||||
|
|
||||||
node_monitor *monitor;
|
node_monitor *monitor;
|
||||||
status_t status = _GetMonitor(context, device, node, true, &monitor,
|
status_t status = _GetMonitor(context, device, node, true, &monitor,
|
||||||
flags & B_WATCH_VOLUME);
|
(flags & B_WATCH_VOLUME) != 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -501,7 +494,7 @@ NodeMonitorService::_UpdateListener(io_context *context, dev_t device,
|
|||||||
|
|
||||||
node_monitor *monitor;
|
node_monitor *monitor;
|
||||||
status_t status = _GetMonitor(context, device, node, false, &monitor,
|
status_t status = _GetMonitor(context, device, node, false, &monitor,
|
||||||
flags | B_WATCH_VOLUME);
|
(flags & B_WATCH_VOLUME) != 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -1006,7 +999,7 @@ NodeMonitorService::UpdateUserListener(io_context *context, dev_t device,
|
|||||||
|
|
||||||
node_monitor *monitor;
|
node_monitor *monitor;
|
||||||
status_t status = _GetMonitor(context, device, node, true, &monitor,
|
status_t status = _GetMonitor(context, device, node, true, &monitor,
|
||||||
flags | B_WATCH_VOLUME);
|
(flags & B_WATCH_VOLUME) != 0);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user