[dmd-concurrency] Shutdown protocol
    Sean Kelly 
    sean at invisibleduck.org
       
    Thu Jan 21 12:08:53 PST 2010
    
    
  
On Jan 21, 2010, at 10:28 AM, Steve Schveighoffer wrote:
> 
> Note that it's not about a few seconds: socket streams are obstinate as a mule. They'll wait for 60-90 seconds to terminate if the connection is infinitely slow.
Yeah, if you want to be sure the system terminates promptly then you can't always count on a clean teardown.  For example, here's the dtor for an IOCP connection I wrote back in the 90s:
cp_connection::~cp_connection()
{
   close();
   for( uint ticks = 0;
        ( !HasOverlappedIoCompleted( &m_ol_send ) || !HasOverlappedIoCompleted( &m_ol_recv ) ) && ticks < 1000;
        ++ticks )
   {
       ::Sleep( 10 );
   }
}
Pretty nasty, but I never actually had the dtor fall through the wait loop in production.
    
    
More information about the dmd-concurrency
mailing list