protected override void ProcessTerm(int linger)
{
Debug.Assert(!m_pending);
// If the termination of the pipe happens before the term command is
// delivered there's nothing much to do. We can proceed with the
// standard termination immediately.
if (m_pipe == null)
{
ProceedWithTerm();
return;
}
m_pending = true;
// If there's finite linger value, delay the termination.
// If linger is infinite (negative) we don't even have to set
// the timer.
if (linger > 0)
{
Debug.Assert(!m_hasLingerTimer);
m_ioObject.AddTimer(linger, LingerTimerId);
m_hasLingerTimer = true;
}
// Start pipe termination process. Delay the termination till all messages
// are processed in case the linger time is non-zero.
m_pipe.Terminate(linger != 0);
// TODO: Should this go into pipe_t::terminate ?
// In case there's no engine and there's only delimiter in the
// pipe it wouldn't be ever read. Thus we check for it explicitly.
m_pipe.CheckRead();
}