diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go index 7aed981de..d12fb9087 100644 --- a/pkg/logger/logger.go +++ b/pkg/logger/logger.go @@ -29,7 +29,6 @@ func initLogger(config zap.Config, level string) { func InitProduction(logLevel string) { initLogger(zap.NewProductionConfig(), logLevel) - } func InitDevelopment(logLevel string) { @@ -37,21 +36,36 @@ func InitDevelopment(logLevel string) { } func Debugw(msg string, keysAndValues ...interface{}) { - getLogger().Debugw(msg, keysAndValues...) + if logger == nil { + return + } + logger.Debugw(msg, keysAndValues...) } func Infow(msg string, keysAndValues ...interface{}) { - getLogger().Infow(msg, keysAndValues...) + if logger == nil { + return + } + logger.Infow(msg, keysAndValues...) } func Warnw(msg string, keysAndValues ...interface{}) { - getLogger().Warnw(msg, keysAndValues...) + if logger == nil { + return + } + logger.Warnw(msg, keysAndValues...) } func Errorw(msg string, keysAndValues ...interface{}) { - getLogger().Errorw(msg, keysAndValues...) + if logger == nil { + return + } + logger.Errorw(msg, keysAndValues...) } func Desugar() *zap.Logger { - return getLogger().Desugar() + if logger == nil { + getLogger() + } + return logger.Desugar() } diff --git a/pkg/rtc/participant.go b/pkg/rtc/participant.go index cc2d89c81..8af30a982 100644 --- a/pkg/rtc/participant.go +++ b/pkg/rtc/participant.go @@ -382,6 +382,7 @@ func (p *ParticipantImpl) SendJoinResponse(roomInfo *livekit.Room, otherParticip } func (p *ParticipantImpl) SendParticipantUpdate(participants []*livekit.ParticipantInfo) error { + return p.responseSink.WriteMessage(&livekit.SignalResponse{ Message: &livekit.SignalResponse_Update{ Update: &livekit.ParticipantUpdate{ diff --git a/pkg/utils/sync.go b/pkg/utils/sync.go index ac1bab3d5..edae9a695 100644 --- a/pkg/utils/sync.go +++ b/pkg/utils/sync.go @@ -10,25 +10,25 @@ var ( ) type AtomicFlag struct { - val uint32 + val int32 } // set flag to value if existing flag is different, otherwise return func (b *AtomicFlag) TrySet(bVal bool) bool { - var v uint32 + var v int32 if bVal { v = 1 } - old := b.val - // value is the same, nochanges - if old == v { + prev := atomic.SwapInt32(&b.val, v) + // already set. unsuccessful + if prev == v { return false } - return atomic.CompareAndSwapUint32(&b.val, old, v) + return true } func (b *AtomicFlag) Get() bool { - return b.val == 1 + return atomic.LoadInt32(&b.val) == 1 } // a channel that ignores writes when it closes instead of panic