Browse Source

Changed MongoConnection to remember the RequestId of the last message sent on this connection.

pull/63/head
rstam 14 years ago
parent
commit
dfb91df761
  1. 10
      Driver/Internal/MongoConnection.cs

10
Driver/Internal/MongoConnection.cs

@ -61,6 +61,7 @@ namespace MongoDB.Driver.Internal {
private DateTime createdAt; private DateTime createdAt;
private DateTime lastUsedAt; // set every time the connection is Released private DateTime lastUsedAt; // set every time the connection is Released
private int messageCounter; private int messageCounter;
private int requestId;
private Dictionary<string, Authentication> authentications = new Dictionary<string, Authentication>(); private Dictionary<string, Authentication> authentications = new Dictionary<string, Authentication>();
#endregion #endregion
@ -105,6 +106,13 @@ namespace MongoDB.Driver.Internal {
get { return messageCounter; } get { return messageCounter; }
} }
/// <summary>
/// Gets the RequestId of the last message sent on this connection.
/// </summary>
public int RequestId {
get { return requestId; }
}
/// <summary> /// <summary>
/// Gets the server instance this connection is connected to. /// Gets the server instance this connection is connected to.
/// </summary> /// </summary>
@ -378,6 +386,8 @@ namespace MongoDB.Driver.Internal {
) { ) {
if (state == MongoConnectionState.Closed) { throw new InvalidOperationException("Connection is closed."); } if (state == MongoConnectionState.Closed) { throw new InvalidOperationException("Connection is closed."); }
lock (connectionLock) { lock (connectionLock) {
requestId = message.RequestId;
message.WriteToBuffer(); message.WriteToBuffer();
CommandDocument safeModeCommand = null; CommandDocument safeModeCommand = null;
if (safeMode.Enabled) { if (safeMode.Enabled) {

Loading…
Cancel
Save