Example #1
0
void Attachment::IdleTimer::handler()
{
	m_fireTime = 0;
	if (!m_expTime)	// Timer was reset to zero, do nothing
		return;

	// Ensure attachment is still alive and idle

	StableAttachmentPart* stable = m_attachment->getStable();
	if (!stable)
		return;

	MutexEnsureUnlock guard(*stable->getMutex(), FB_FUNCTION);
	if (!guard.tryEnter())
		return;

	if (!m_expTime)
		return;

	// If timer was reset to fire later, restart ITimer
	time_t curTime = time(NULL);
	if (curTime < m_expTime)
	{
		reset(m_expTime - curTime);
		return;
	}

	Attachment* att = stable->getHandle();
	att->signalShutdown(isc_att_shut_idle);
	JRD_shutdown_attachment(att);
}