public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Tad <ecos_removethispart@ds3switch.com>
To: ecos-discuss@sources.redhat.com
Subject: [ECOS] SNMP re-inits when session closed or trapsink removed -- FIX
Date: Fri, 15 Jun 2007 18:06:00 -0000	[thread overview]
Message-ID: <46726D19.50602@ds3switch.com> (raw)

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

             reply	other threads:[~2007-06-15  9:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-15 18:06 Tad [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46726D19.50602@ds3switch.com \
    --to=ecos_removethispart@ds3switch.com \
    --cc=ecos-discuss@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).