Skip to content

Commit

Permalink
docs: 修复 server 在 WebSocket 模式下超时时间无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
kercylan98 committed Sep 19, 2023
1 parent 0cc8fd8 commit 1bc32e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 1 addition & 6 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/kercylan98/minotaur/utils/str"
"github.com/kercylan98/minotaur/utils/super"
"github.com/kercylan98/minotaur/utils/timer"
"github.com/kercylan98/minotaur/utils/times"
"github.com/panjf2000/ants/v2"
"github.com/panjf2000/gnet"
"github.com/panjf2000/gnet/pkg/logging"
Expand Down Expand Up @@ -319,13 +318,9 @@ func (slf *Server) Run(addr string) error {
conn.Close(e)
}
}()
var deadline = times.Zero
if slf.websocketReadDeadline > 0 {
deadline = time.Now().Add(slf.websocketReadDeadline)
}
for !conn.IsClosed() {
if slf.websocketReadDeadline > 0 {
if err := ws.SetReadDeadline(deadline); err != nil {
if err := ws.SetReadDeadline(time.Now().Add(slf.websocketReadDeadline)); err != nil {
panic(err)
}
}
Expand Down
6 changes: 6 additions & 0 deletions utils/concurrent/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ func (slf *Pool[T]) IsClose() bool {
}

func (slf *Pool[T]) Release(data T) {
slf.mutex.Lock()
if slf.releaser == nil {
slf.mutex.Unlock()
return
}
slf.releaser(data)
slf.mutex.Unlock()
slf.put(data)
}

Expand Down

0 comments on commit 1bc32e2

Please sign in to comment.