(connID string)
| 158 | } |
| 159 | |
| 160 | func (st *StreamTracker) CloseStream(connID string) { |
| 161 | st.mu.RLock() |
| 162 | conn := st.connMap[connID] |
| 163 | st.mu.RUnlock() |
| 164 | if conn == nil { |
| 165 | return |
| 166 | } |
| 167 | if res := conn.Dec(); res == 0 { |
| 168 | // Delete the entry if it's empty. |
| 169 | st.mu.Lock() |
| 170 | |
| 171 | // Get the entry again to avoid race condition. |
| 172 | conn = st.connMap[connID] |
| 173 | if conn == nil || conn.Load() == 0 { |
| 174 | delete(st.connMap, connID) |
| 175 | } |
| 176 | |
| 177 | st.mu.Unlock() |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | // MaxStreams returns the number of streams in the connection with the most streams. |
| 182 | func (st *StreamTracker) MaxStreams() int { |
no outgoing calls