docs: 修复 server 在 WebSocket 模式下超时时间无效的问题

This commit is contained in:
kercylan98 2023-09-19 15:45:12 +08:00
parent 0cc8fd8186
commit 1bc32e2026
2 changed files with 7 additions and 6 deletions

View File

@ -13,7 +13,6 @@ import (
"github.com/kercylan98/minotaur/utils/str" "github.com/kercylan98/minotaur/utils/str"
"github.com/kercylan98/minotaur/utils/super" "github.com/kercylan98/minotaur/utils/super"
"github.com/kercylan98/minotaur/utils/timer" "github.com/kercylan98/minotaur/utils/timer"
"github.com/kercylan98/minotaur/utils/times"
"github.com/panjf2000/ants/v2" "github.com/panjf2000/ants/v2"
"github.com/panjf2000/gnet" "github.com/panjf2000/gnet"
"github.com/panjf2000/gnet/pkg/logging" "github.com/panjf2000/gnet/pkg/logging"
@ -319,13 +318,9 @@ func (slf *Server) Run(addr string) error {
conn.Close(e) conn.Close(e)
} }
}() }()
var deadline = times.Zero
if slf.websocketReadDeadline > 0 {
deadline = time.Now().Add(slf.websocketReadDeadline)
}
for !conn.IsClosed() { for !conn.IsClosed() {
if slf.websocketReadDeadline > 0 { if slf.websocketReadDeadline > 0 {
if err := ws.SetReadDeadline(deadline); err != nil { if err := ws.SetReadDeadline(time.Now().Add(slf.websocketReadDeadline)); err != nil {
panic(err) panic(err)
} }
} }

View File

@ -71,7 +71,13 @@ func (slf *Pool[T]) IsClose() bool {
} }
func (slf *Pool[T]) Release(data T) { func (slf *Pool[T]) Release(data T) {
slf.mutex.Lock()
if slf.releaser == nil {
slf.mutex.Unlock()
return
}
slf.releaser(data) slf.releaser(data)
slf.mutex.Unlock()
slf.put(data) slf.put(data)
} }