public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] SNMP re-inits when session closed or trapsink removed -- FIX
@ 2007-06-15 18:06 Tad
  2007-06-15 18:41 ` Andrew Lunn
  0 siblings, 1 reply; 5+ messages in thread
From: Tad @ 2007-06-15 18:06 UTC (permalink / raw)
  To: ecos-discuss

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-15 19:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-06-15 18:06 [ECOS] SNMP re-inits when session closed or trapsink removed -- FIX Tad
2007-06-15 18:41 ` Andrew Lunn
2007-06-17 19:53   ` Tad
2007-06-17 19:58     ` Andrew Lunn
2007-06-17 21:41       ` Tad

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).