downstream: atomically ack/nak capabilities

This commit is contained in:
Simon Ser 2022-03-14 19:30:29 +01:00
parent 6e094b1099
commit 35b09f069c

View File

@ -875,9 +875,9 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
}}
}
// TODO: atomically ack/nak the whole capability set
caps := strings.Fields(args[0])
ack := true
m := make(map[string]bool, len(caps))
for _, name := range caps {
name = strings.ToLower(name)
enable := !strings.HasPrefix(name, "-")
@ -900,8 +900,15 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
break
}
m[name] = enable
}
// Atomically ack the whole capability set
if ack {
for name, enable := range m {
dc.caps.SetEnabled(name, enable)
}
}
reply := "NAK"
if ack {