Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-187

BsonBuffer waiting indefinitely on broken connection

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.1
    • Affects Version/s: 1.0
    • Component/s: None
    • None

      BsonBuffer.LoadFrom contains the following loop:

      while (bytesPending > 0) {
      var bytesRead = stream.Read(localChunk, localChunkOffset, bytesPending);
      if (bytesRead == 0)

      { // TODO: timeout? Thread.Sleep(5); // just enough to not be busy waiting }

      else

      { localChunkOffset += bytesRead; bytesPending -= bytesRead; }

      }

      The "timeout" is a necessity here, since when the connection is gracefully closed from the MongoDB side (by stopping the server), the client connection remains active:
      netstat -a -n | find ":27017"
      TCP client:5171 mongodb:27017 CLOSE_WAIT

      This leads to an endless loop that just hangs the client thread when the server is gone.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            onyxmaster Aristarkh Zagorodnikov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: