Skip to content

Commit fc92b90

Browse files
committed
websocket: address PR2201 review thread fixes
1 parent 753f0cf commit fc92b90

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

exchange/websocket/manager.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,8 @@ func (m *Manager) connect(ctx context.Context) error {
512512
var subscriptionError error
513513

514514
// TODO: Implement concurrency below.
515-
for i := range connectionManager {
515+
for i, ws := range connectionManager {
516516
var subs subscription.List
517-
ws := connectionManager[i]
518517
if !ws.setup.SubscriptionsNotRequired {
519518
if ws.setup.GenerateSubscriptions == nil {
520519
multiConnectFatalError = fmt.Errorf("cannot connect to [conn:%d] [URL:%s]: %w ", i+1, ws.setup.URL, errWebsocketSubscriptionsGeneratorUnset)
@@ -880,7 +879,7 @@ func (m *Manager) GetWebsocketURL() string {
880879

881880
// GetConfiguredWebsocketURLs returns known websocket connection URLs.
882881
func (m *Manager) GetConfiguredWebsocketURLs() []string {
883-
if err := common.NilGuard(m); err != nil {
882+
if m == nil {
884883
return nil
885884
}
886885

exchange/websocket/subscriptions.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,11 @@ func (m *Manager) GetSubscription(key any) *subscription.Subscription {
209209
for _, ws := range m.snapshotConnectionManager() {
210210
m.subscriptionsMu.RLock()
211211
store := ws.subscriptions
212-
m.subscriptionsMu.RUnlock()
213-
if store == nil {
214-
continue
212+
var sub *subscription.Subscription
213+
if store != nil {
214+
sub = store.Get(key)
215215
}
216-
sub := store.Get(key)
216+
m.subscriptionsMu.RUnlock()
217217
if sub != nil {
218218
return sub
219219
}
@@ -233,10 +233,10 @@ func (m *Manager) GetSubscriptions() subscription.List {
233233
for _, ws := range m.snapshotConnectionManager() {
234234
m.subscriptionsMu.RLock()
235235
store := ws.subscriptions
236-
m.subscriptionsMu.RUnlock()
237236
if store != nil {
238237
subs = append(subs, store.List()...)
239238
}
239+
m.subscriptionsMu.RUnlock()
240240
}
241241
if store := m.subscriptionStore(nil); store != nil {
242242
subs = append(subs, store.List()...)

0 commit comments

Comments
 (0)