mirror of https://github.com/tidwall/tile38.git
Fix multiple matches on different key hooks
This commit is contained in:
parent
b6977da0c4
commit
6b2fc1f37f
|
@ -211,6 +211,9 @@ func (server *Server) getQueueCandidates(d *commandDetails) []*Hook {
|
|||
[]float64{rect.Max.X, rect.Max.Y},
|
||||
func(_, _ []float64, value interface{}) bool {
|
||||
hook := value.(*Hook)
|
||||
if hook.Key != d.key {
|
||||
return true
|
||||
}
|
||||
var found bool
|
||||
for _, candidate := range candidates {
|
||||
if candidate == hook {
|
||||
|
|
|
@ -233,11 +233,9 @@ func (c *Server) cmdDelHook(msg *Message, chanCmd bool) (
|
|||
}
|
||||
if hook, ok := c.hooks[name]; ok && hook.channel == chanCmd {
|
||||
hook.Close()
|
||||
// remove hook from maps
|
||||
delete(c.hooks, hook.Name)
|
||||
delete(c.hooksOut, hook.Name)
|
||||
|
||||
d.updated = true
|
||||
|
||||
// remove hook from spatial index
|
||||
if hook != nil && hook.Fence != nil && hook.Fence.obj != nil {
|
||||
rect := hook.Fence.obj.Rect()
|
||||
|
@ -246,6 +244,7 @@ func (c *Server) cmdDelHook(msg *Message, chanCmd bool) (
|
|||
[]float64{rect.Max.X, rect.Max.Y},
|
||||
hook)
|
||||
}
|
||||
d.updated = true
|
||||
}
|
||||
d.timestamp = time.Now()
|
||||
|
||||
|
@ -277,16 +276,26 @@ func (c *Server) cmdPDelHook(msg *Message, channel bool) (
|
|||
}
|
||||
|
||||
count := 0
|
||||
for name, h := range c.hooks {
|
||||
if h.channel != channel {
|
||||
for name, hook := range c.hooks {
|
||||
if hook.channel != channel {
|
||||
continue
|
||||
}
|
||||
match, _ := glob.Match(pattern, name)
|
||||
if !match {
|
||||
continue
|
||||
}
|
||||
h.Close()
|
||||
delete(c.hooks, h.Name)
|
||||
hook.Close()
|
||||
// remove hook from maps
|
||||
delete(c.hooks, hook.Name)
|
||||
delete(c.hooksOut, hook.Name)
|
||||
// remove hook from spatial index
|
||||
if hook != nil && hook.Fence != nil && hook.Fence.obj != nil {
|
||||
rect := hook.Fence.obj.Rect()
|
||||
c.hookTree.Delete(
|
||||
[]float64{rect.Min.X, rect.Min.Y},
|
||||
[]float64{rect.Max.X, rect.Max.Y},
|
||||
hook)
|
||||
}
|
||||
d.updated = true
|
||||
count++
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue