mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-28 03:07:07 +02:00
fix(websocket): ensure resources are properly released by closing the manager in PeriodicWrite function
This commit is contained in:
@@ -82,6 +82,7 @@ func PeriodicWrite(c *gin.Context, interval time.Duration, get func() (any, erro
|
|||||||
c.Error(apitypes.InternalServerError(err, "failed to upgrade to websocket"))
|
c.Error(apitypes.InternalServerError(err, "failed to upgrade to websocket"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer manager.Close()
|
||||||
err = manager.PeriodicWrite(interval, get)
|
err = manager.PeriodicWrite(interval, get)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Error(apitypes.InternalServerError(err, "failed to write to websocket"))
|
c.Error(apitypes.InternalServerError(err, "failed to write to websocket"))
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ func getHTTPFlusher(dst io.Writer) flushErrorInterface {
|
|||||||
|
|
||||||
const copyBufSize = synk.SizedPoolThreshold
|
const copyBufSize = synk.SizedPoolThreshold
|
||||||
|
|
||||||
var bytesPool = synk.NewBytesPool()
|
var bytesPool = synk.GetBytesPool()
|
||||||
|
|
||||||
// Copyright 2009 The Go Authors. All rights reserved.
|
// Copyright 2009 The Go Authors. All rights reserved.
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
|
|||||||
Reference in New Issue
Block a user