Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier committed Nov 15, 2024
1 parent 9a761f9 commit c060474
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions csharp/src/Ice/Internal/IdleTimeoutTransceiverDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#nullable enable

using System.Collections;
using System.Diagnostics;
using System.Net.Sockets;

Expand Down Expand Up @@ -99,7 +98,11 @@ public int write(Buffer buf)
return op;
}

internal IdleTimeoutTransceiverDecorator(Transceiver decoratee, ConnectionI connection, TimeSpan idleTimeout, bool enableIdleCheck)
internal IdleTimeoutTransceiverDecorator(
Transceiver decoratee,
ConnectionI connection,
TimeSpan idleTimeout,
bool enableIdleCheck)
{
Debug.Assert(idleTimeout > TimeSpan.Zero);

Expand All @@ -109,18 +112,18 @@ internal IdleTimeoutTransceiverDecorator(Transceiver decoratee, ConnectionI conn
if (enableIdleCheck)
{
_readTimer = new System.Threading.Timer(_ => connection.idleCheck(_idleTimeout));
}
idleCheckEnabled = enableIdleCheck;

// idleCheckEnabled remains false for now. ConnectionI calls enableIdleCheck() when it becomes Active to
// schedule the first idle check and set idleCheckEnabled to true.
// We don't want the idle check to start when a client connection is waiting for the initial
// ValidateConnection message or when a server connection is in its initial StateHolding state.
}
_writeTimer = new System.Threading.Timer(_ => connection.sendHeartbeat());
}

internal void enableIdleCheck()
{
// idleCheckEnabled is already true when enableIdleCheck() is called on a TCP server connection that becomes
// Active for the first time.

if (_readTimer is not null)
if (!idleCheckEnabled && _readTimer is not null)
{
rescheduleReadTimer();
idleCheckEnabled = true;
Expand Down

0 comments on commit c060474

Please sign in to comment.