mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
iceCandidatesMu.
This commit is contained in:
parent
bb35695255
commit
e4261c53b1
@ -15,6 +15,7 @@ type metrics struct {
|
|||||||
connectionCount prometheus.Counter
|
connectionCount prometheus.Counter
|
||||||
|
|
||||||
iceCandidates map[string]struct{}
|
iceCandidates map[string]struct{}
|
||||||
|
iceCandidatesMu *sync.Mutex
|
||||||
iceCandidatesCount prometheus.Counter
|
iceCandidatesCount prometheus.Counter
|
||||||
|
|
||||||
iceBytesSent prometheus.Gauge
|
iceBytesSent prometheus.Gauge
|
||||||
@ -74,6 +75,7 @@ func (m *metricsCtx) getBySession(session types.Session) metrics {
|
|||||||
}),
|
}),
|
||||||
|
|
||||||
iceCandidates: map[string]struct{}{},
|
iceCandidates: map[string]struct{}{},
|
||||||
|
iceCandidatesMu: &sync.Mutex{},
|
||||||
iceCandidatesCount: promauto.NewCounter(prometheus.CounterOpts{
|
iceCandidatesCount: promauto.NewCounter(prometheus.CounterOpts{
|
||||||
Name: "ice_candidates_count",
|
Name: "ice_candidates_count",
|
||||||
Namespace: "neko",
|
Namespace: "neko",
|
||||||
@ -135,6 +137,9 @@ func (m *metricsCtx) NewConnection(session types.Session) {
|
|||||||
func (m *metricsCtx) NewICECandidate(session types.Session, id string) {
|
func (m *metricsCtx) NewICECandidate(session types.Session, id string) {
|
||||||
met := m.getBySession(session)
|
met := m.getBySession(session)
|
||||||
|
|
||||||
|
met.iceCandidatesMu.Lock()
|
||||||
|
defer met.iceCandidatesMu.Unlock()
|
||||||
|
|
||||||
if _, found := met.iceCandidates[id]; found {
|
if _, found := met.iceCandidates[id]; found {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user