Skip to content

Commit 9da818d

Browse files
committed
Fix race condition with handshaker for connections
GODRIVER-901 Change-Id: I4a41bff911bd6115c0de988f91dab3940f99c07c
1 parent 65ca1b1 commit 9da818d

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ update-notices:
103103

104104
.PHONY: vet
105105
vet:
106-
go vet -cgocall=false -composites=false -structtags=false -unusedstringmethods="Error" $(PKGS)
106+
go vet -cgocall=false -composites=false -unusedstringmethods="Error" $(PKGS)
107107

108108

109109
# Evergreen specific targets

mongo/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ func (c *Client) configure(opts *options.ClientOptions) error {
230230
))
231231
}
232232
// Handshaker
233-
var handshaker connection.Handshaker = &command.Handshake{Client: command.ClientDoc(appName), Compressors: comps}
233+
var handshaker = func(connection.Handshaker) connection.Handshaker {
234+
return &command.Handshake{Client: command.ClientDoc(appName), Compressors: comps}
235+
}
234236
// Auth & Database & Password & Username
235237
if opts.Auth != nil {
236238
cred := &auth.Cred{
@@ -272,11 +274,11 @@ func (c *Client) configure(opts *options.ClientOptions) error {
272274
}
273275
}
274276

275-
handshaker = auth.Handshaker(nil, handshakeOpts)
277+
handshaker = func(connection.Handshaker) connection.Handshaker {
278+
return auth.Handshaker(nil, handshakeOpts)
279+
}
276280
}
277-
connOpts = append(connOpts, connection.WithHandshaker(
278-
func(connection.Handshaker) connection.Handshaker { return handshaker },
279-
))
281+
connOpts = append(connOpts, connection.WithHandshaker(handshaker))
280282
// ConnectTimeout
281283
if opts.ConnectTimeout != nil {
282284
serverOpts = append(serverOpts, topology.WithHeartbeatTimeout(

mongo/gridfs/bucket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ func (b *Bucket) openDownloadStream(filter interface{}, opts ...*options.FindOpt
354354
default:
355355
fileLen = fileLenElem.Int64()
356356
}
357-
357+
358358
if fileLen == 0 {
359359
return newDownloadStream(nil, b.chunkSize, 0), nil
360360
}

0 commit comments

Comments
 (0)