Skip to content

Commit

Permalink
fix hb
Browse files Browse the repository at this point in the history
  • Loading branch information
snail007 committed Feb 4, 2025
1 parent b425e4f commit c52e34e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion util/batch/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (s *Executor) waitFirst(checkSuccess bool) (value interface{}, err error) {
if len(s.tasks) == 0 {
return nil, errors.New("tasks is empty")
}
waitChan := make(chan taskResult)
waitChan := make(chan taskResult, 1)
allResult := glist.New()
p := gpool.New(s.workers)
defer p.Stop()
Expand Down
2 changes: 1 addition & 1 deletion util/func/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func CheckError3(v1 interface{}, v2 interface{}, err error) (*gvalue.AnyValue, *
}

func Wait(f func()) <-chan error {
ch := make(chan error)
ch := make(chan error, 1)
go func() {
ch <- SafetyCall(f)
}()
Expand Down
9 changes: 4 additions & 5 deletions util/net/heartbeat_codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *HeartbeatCodec) tempDelay(tempDelay time.Duration) time.Duration {
return tempDelay
}
func (s *HeartbeatCodec) heartbeat() {
done := make(chan error)
done := make(chan error, 1)
tempDelay := time.Duration(0)
p := gpool.New(1)
retry:
Expand Down Expand Up @@ -196,7 +196,7 @@ retry:
func (s *HeartbeatCodec) backgroundRead() {
tempDelay := time.Duration(0)
msg := newHeartbeatCodecMsg()
out := make(chan error)
out := make(chan error, 1)
p := gpool.New(1)
retry:
for {
Expand Down Expand Up @@ -235,11 +235,10 @@ func (s *HeartbeatCodec) SetConn(c net.Conn) Codec {
}

func (s *HeartbeatCodec) Read(b []byte) (n int, err error) {
done := make(chan bool)
done := make(chan bool, 1)
s.readPool.Submit(func() {
defer close(done)
n, err = s.bufReader.Read(b)
_ = err
})
select {
case <-done:
Expand All @@ -253,7 +252,7 @@ func (s *HeartbeatCodec) Write(b []byte) (n int, err error) {
defer s.Unlock()
msg := newHeartbeatCodecMsg()
msg.SetData(b)
done := make(chan bool)
done := make(chan bool, 1)
p := s.writePool
if len(b) == 0 {
p = s.writeHbPool
Expand Down

0 comments on commit c52e34e

Please sign in to comment.