globalsign / mgo

The MongoDB driver for Go
Other
1.97k stars 232 forks source link

fix connection full bug #373

Open vinllen opened 5 years ago

vinllen commented 5 years ago

bugfix of connection full, see #322 and #346 . Here is a brief of my modification: liveSockets means unused connections and used connections, unusedSockets means unused connections. However, a connection won't be released even if it's an "unused" connection. So this comparison only restricts the used connections but not the total connections. So in my understanding, this comparison(len(server.liveSockets)-len(server.unusedSockets) >= poolLimit) can only limit the total connections but not used connections. The right comparison should be: len(server.liveSockets) >= poolLimit && len(server.unusedSockets) == 0。 This modification has already been merged and verified in my mgo branch which is used in MongoShake tools.