Skip to content

Commit

Permalink
go/runtime: fix race in connectorProxy
Browse files Browse the repository at this point in the history
Don't tell the client about a connector proxy ID we haven't actually
started or indexed yet.
  • Loading branch information
jgraettinger committed Sep 5, 2024
1 parent 319acfc commit 9264264
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions go/runtime/connector_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func (s *connectorProxy) ProxyConnectors(stream pr.ConnectorProxy_ProxyConnector
// Unique id for this proxy, that we'll pass back to the client.
var id = fmt.Sprintf("connector-proxy-%d", time.Now().UnixNano())

_ = stream.Send(&pr.ConnectorProxyResponse{
Address: s.address,
ProxyId: id,
})
svc, err := bindings.NewTaskService(
pr.TaskServiceConfig{
AllowLocal: s.host.Config.Flow.AllowLocal,
Expand Down Expand Up @@ -76,6 +72,12 @@ func (s *connectorProxy) ProxyConnectors(stream pr.ConnectorProxy_ProxyConnector
svc.Drop()
}()

// Now that we've indexed `id`, tell the client about it.
_ = stream.Send(&pr.ConnectorProxyResponse{
Address: s.address,
ProxyId: id,
})

// Block until we read EOF, signaling a graceful shutdown.
for {
if _, err = stream.Recv(); err == nil {
Expand Down

0 comments on commit 9264264

Please sign in to comment.