Skip to content

Commit

Permalink
Merge pull request #237 from taosdata/enh/xftan/TS-4129-3.0
Browse files Browse the repository at this point in the history
enh: free message after poll
  • Loading branch information
huskar-t authored Nov 24, 2023
2 parents 369eb70 + d43e860 commit 199626b
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 819 deletions.
9 changes: 1 addition & 8 deletions controller/ws/query/ws.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"unsafe"

"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/huskar-t/melody"
"github.com/sirupsen/logrus"
"github.com/taosdata/driver-go/v3/common/parser"
Expand Down Expand Up @@ -179,13 +178,7 @@ func NewQueryController() *QueryController {
})

queryM.HandleError(func(session *melody.Session, err error) {
logger := session.MustGet("logger").(*logrus.Entry)
_, is := err.(*websocket.CloseError)
if is {
logger.WithError(err).Debugln("ws close in error")
} else {
logger.WithError(err).Errorln("ws error")
}
wstool.LogWSError(session, err)
t, exist := session.Get(TaosSessionKey)
if exist && t != nil {
t.(*Taos).Close()
Expand Down
8 changes: 6 additions & 2 deletions controller/ws/schemaless/schemaless.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,13 @@ func NewSchemalessController() *SchemalessController {

schemaless.HandleError(func(session *melody.Session, err error) {
logger := session.MustGet("logger").(*logrus.Entry)
_, is := err.(*websocket.CloseError)
wsCloseErr, is := err.(*websocket.CloseError)
if is {
logger.WithError(err).Debugln("ws close in error")
if wsCloseErr.Code == websocket.CloseNormalClosure {
logger.Debugln("ws close normal")
} else {
logger.WithError(err).Debugln("ws close in error")
}
} else {
logger.WithError(err).Errorln("ws error")
}
Expand Down
9 changes: 1 addition & 8 deletions controller/ws/stmt/stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"unsafe"

"github.com/gin-gonic/gin"
"github.com/gorilla/websocket"
"github.com/huskar-t/melody"
"github.com/sirupsen/logrus"
"github.com/taosdata/driver-go/v3/common"
Expand Down Expand Up @@ -216,13 +215,7 @@ func NewSTMTController() *STMTController {
})

stmtM.HandleError(func(session *melody.Session, err error) {
logger := session.MustGet("logger").(*logrus.Entry)
_, is := err.(*websocket.CloseError)
if is {
logger.WithError(err).Debugln("ws close in error")
} else {
logger.WithError(err).Errorln("ws error")
}
wstool.LogWSError(session, err)
t, exist := session.Get(TaosStmtKey)
if exist && t != nil {
t.(*TaosStmt).Close()
Expand Down
Loading

0 comments on commit 199626b

Please sign in to comment.