[AGENT++] SNMP++ Slow socket closing and SNMP_CLASS_TL_IN_USE

Jochen Katz katz at agentpp.com
Wed Jan 17 23:11:05 CET 2007


Hi,

> This time it's about Snmp::notify_register() returning
> SNMP_CLASS_TL_IN_USE when called several consequtive times. I tested
> it both under Win32 and Linux and it happens only under Linux.

just to be sure: you call notify_register() right after
notify_unregister() and then notify_register() returns SNMP_CLASS_TL_IN_USE.

> As far as I understand the socket does not get closed during the call
> to close() and when bind is attempted again in a very short time
> (several mls) the address/port seem to already be in use.
> 
> It seems that using SO_REUSEADDR (or maybe SO_LINGER but this could
> be more complex because of getting the right timeout value) would
> solve the problem.

Until now, I never heard of UDP sockets having a TIME_WAIT phase like
TCP... If you're right the following code in
CNotifyEventQueue::AddEntry() should solve it:

	int ii = 1;
	if (setsockopt(m_notify_fds[i], SOL_SOCKET, SO_REUSEADDR,
	              (const char *)&ii,
		       sizeof(ii)) < 0 ) {
		LOG_BEGIN(ERROR_LOG | 1);
		LOG("setsockopt failed, but it is ignored (errno)");
		LOG(errno);
		LOG_END;
	}

Could you test this and report if it works and solves your problem?

Regards,
  Jochen




More information about the AGENTPP mailing list