淇敼锛歵opic & message chan overload check

git-svn-id: svn://47.119.165.148/zhub@129 e63fbceb-bcc3-4977-ac22-735b83d8d0f4
This commit is contained in:
lxy
2021-09-25 17:38:31 +00:00
parent b5e55c9869
commit df84efffce
2 changed files with 20 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package zsub
import (
"bufio"
"fmt"
"log"
"net"
"os"
@@ -369,8 +370,15 @@ func (s *ZSub) Publish(topic, msg string) {
if ztopic == nil {
return
}
ztopic.chMsg <- msg
ztopic.mcount++
// topic chan overload check
if len(ztopic.chMsg) == cap(ztopic.chMsg) {
log.Println(fmt.Sprintf("ztopic no cap: [%s %s]", topic, msg))
return
}
ztopic.chMsg <- msg
}
/*