Skip to content

Commit a764a96

Browse files
committed
graffiti: fix races when a subscriber with a filter connects
1 parent 6020dbc commit a764a96

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

graffiti/common/subscriber_endpoint.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,16 @@ func (t *SubscriberEndpoint) OnConnected(c ws.Speaker) {
8787
if gremlinFilter != "" {
8888
host := c.GetRemoteHost()
8989

90-
subscriber, err := t.newSubscriber(host, gremlinFilter, false)
90+
subscriber, err := t.newSubscriber(host, gremlinFilter, true)
9191
if err != nil {
9292
logging.GetLogger().Error(err)
9393
return
9494
}
9595

9696
logging.GetLogger().Infof("Client %s subscribed with filter %s during the connection", host, gremlinFilter)
97+
t.Lock()
9798
t.subscribers[c] = subscriber
99+
t.Unlock()
98100
}
99101
}
100102

0 commit comments

Comments
 (0)