fix: adding lock for cancel function slices
This commit is contained in:
@@ -235,7 +235,10 @@ func (wsClient *SafeWebsocketClient) connect() error {
|
|||||||
|
|
||||||
pingCtx, pingCancel := context.WithCancel(context.Background())
|
pingCtx, pingCancel := context.WithCancel(context.Background())
|
||||||
go wsClient.startPingTicker(pingCtx)
|
go wsClient.startPingTicker(pingCtx)
|
||||||
|
wsClient.mu.WriteHandler(func() error {
|
||||||
wsClient.cancelFuncs = append(wsClient.cancelFuncs, pingCancel)
|
wsClient.cancelFuncs = append(wsClient.cancelFuncs, pingCancel)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
if wsClient.conn != nil {
|
if wsClient.conn != nil {
|
||||||
wsClient.conn.Close()
|
wsClient.conn.Close()
|
||||||
@@ -251,7 +254,10 @@ func (wsClient *SafeWebsocketClient) connect() error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
wsClient.mu.WriteHandler(func() error {
|
||||||
wsClient.cancelFuncs = append(wsClient.cancelFuncs, cancel)
|
wsClient.cancelFuncs = append(wsClient.cancelFuncs, cancel)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
@@ -285,7 +291,10 @@ func (wsClient *SafeWebsocketClient) connect() error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
wsClient.mu.WriteHandler(func() error {
|
||||||
wsClient.cancelFuncs = append(wsClient.cancelFuncs, cancel)
|
wsClient.cancelFuncs = append(wsClient.cancelFuncs, cancel)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|||||||
Reference in New Issue
Block a user