This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
SNMP re-inits when session closed or trapsink removed -- FIX
- From: Tad <ecos_removethispart at ds3switch dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Fri, 15 Jun 2007 02:42:33 -0800
- Subject: [ECOS] SNMP re-inits when session closed or trapsink removed -- FIX
If an SNMP session is closed or a trapsink is removed (which closes a
session), the main select loop of snmpd will fail and re-init SNMP.
The cause appears to be outstanding select which returne EBADF = bad
file descriptor(pointer?) for the socket that was closed out from under it.
Didn't know where this should be posted for the net-snmp guys, esp,
cause I don't know if it affects their tree. They don't have this fix
as below in their latest. Any suggestions on this question?
The simple fix appears to be to simply continue as if nothing happened,
but it's possible that snmp_select_info() never should have added the
closing socket to fdset in the first place. It was getting very hard
for me to determine whether the select was already outstanding when the
socket closed or whether someone didn't set a proper "closing" flag that
snmp_select_info() would recognize. I tried updating the
snmp_select_info() to rev 1.245 of the 4.2 net-snmp tree which looks at
closing sessions, but that didn't seem to help.
Here's the quick fix. Most people probably don't close trapsinks too
often and perhaps didn't even notice snmp re-init when they did.
snmpd.c : receive()
...
count = select(numfds, &fdset, 0, 0, tvp);
if (count > 0){
snmp_read(&fdset);
} else switch(count){
case 0:
snmp_timeout();
break;
case -1:
- if (errno == EINTR){
+ if (errno == EINTR || errno == EBADF){
continue;
} else {
snmp_log_perror("select");
}
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss