mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 15:26:40 +00:00
Handle the stream sending in thread safe way
This commit is contained in:
@@ -44,6 +44,7 @@ func (k *KeepAlive) StreamInterceptor() grpc.StreamServerInterceptor {
|
||||
}
|
||||
|
||||
m := &ioMonitor{
|
||||
sync.Mutex{},
|
||||
sync.Mutex{},
|
||||
stream,
|
||||
time.Now(),
|
||||
|
||||
@@ -8,13 +8,16 @@ import (
|
||||
)
|
||||
|
||||
type ioMonitor struct {
|
||||
mu sync.Mutex
|
||||
mu sync.Mutex
|
||||
streamLock sync.Mutex
|
||||
grpc.ServerStream
|
||||
lastSeen time.Time
|
||||
}
|
||||
|
||||
func (l *ioMonitor) sendMsg(m interface{}) error {
|
||||
l.updateLastSeen()
|
||||
l.streamLock.Lock()
|
||||
defer l.streamLock.Unlock()
|
||||
return l.ServerStream.SendMsg(m)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user