Make onNegotiationNeeded conform to spec

- Removes non-canon logic
This commit is contained in:
Eric Daniels
2024-06-24 10:54:41 -04:00
parent d56bead6a6
commit 1bb9fa9020
5 changed files with 66 additions and 96 deletions

View File

@@ -16,11 +16,19 @@ type operations struct {
mu sync.Mutex
busy bool
ops *list.List
updateNegotiationNeededFlagOnEmptyChain *atomicBool
onNegotiationNeeded func()
}
func newOperations() *operations {
func newOperations(
updateNegotiationNeededFlagOnEmptyChain *atomicBool,
onNegotiationNeeded func(),
) *operations {
return &operations{
ops: list.New(),
ops: list.New(),
updateNegotiationNeededFlagOnEmptyChain: updateNegotiationNeededFlagOnEmptyChain,
onNegotiationNeeded: onNegotiationNeeded,
}
}
@@ -93,4 +101,9 @@ func (o *operations) start() {
fn()
fn = o.pop()
}
if !o.updateNegotiationNeededFlagOnEmptyChain.get() {
return
}
o.updateNegotiationNeededFlagOnEmptyChain.set(false)
o.onNegotiationNeeded()
}