mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
fix: concurrent write to single WebSocket connection (#392)
This commit is contained in:
parent
34fedd91d2
commit
f95191c8af
@ -120,7 +120,7 @@ func (m *Monitor) AfterFind(tx *gorm.DB) error {
|
||||
|
||||
// IsServiceSentinelNeeded 判断该任务类型是否需要进行服务监控 需要则返回true
|
||||
func IsServiceSentinelNeeded(t uint64) bool {
|
||||
return t != TaskTypeCommand && t != TaskTypeTerminal && t != TaskTypeUpgrade
|
||||
return t != TaskTypeCommand && t != TaskTypeTerminalGRPC && t != TaskTypeUpgrade
|
||||
}
|
||||
|
||||
func (m *Monitor) InitSkipServers() error {
|
||||
|
@ -28,6 +28,12 @@ func (conn *Conn) Write(data []byte) (int, error) {
|
||||
return len(data), nil
|
||||
}
|
||||
|
||||
func (conn *Conn) WriteMessage(messageType int, data []byte) error {
|
||||
conn.writeLock.Lock()
|
||||
defer conn.writeLock.Unlock()
|
||||
return conn.Conn.WriteMessage(messageType, data)
|
||||
}
|
||||
|
||||
func (conn *Conn) Read(data []byte) (int, error) {
|
||||
if len(conn.dataBuf) > 0 {
|
||||
n := copy(data, conn.dataBuf)
|
||||
|
Loading…
Reference in New Issue
Block a user