On 05/15/15 16:42, Dixon Xavier wrote:
This is the output collected by running:
./snmptrapd -f -Dall -Lo
...
trace: snmp_sess_select_info2_flags(): snmp_api.c, 6046:
sess_select: for all sessions: 7 5 3
sess_select: next alarm at 1431718589.066441 sec
verbose:sess_select: timer due in 4.483267 sec
verbose:sess_select: setting timer to 4.483267 sec, clear block (was 0)
trace: snmptrapd_main_loop(): snmptrapd.c, 593:
snmptrapd/main_loop: after snmp_select_info numfds: 8.
trace: snmptrapd_main_loop(): snmptrapd.c, 596:
snmptrapd/main_loop: fd 35 is set. trace: snmptrapd_main_loop():
snmptrapd.c, 596:
snmptrapd/main_loop: fd 37 is set. trace: snmptrapd_main_loop():
snmptrapd.c, 596:
snmptrapd/main_loop: fd 39 is set. trace: snmptrapd_main_loop():
snmptrapd.c, 599:
snmptrapd/main_loop:
...

:
From sess_select sockets found are 7 5 3.
But those are interpreted by hp-ux system's FD_ macros as fd 35, 37, 39 are set.
This causes issue and select is not able to know when trap arrives.

Would it be possible to test the attached patch on top of the latest v5.7 git code ?

Thanks,

Bart.
>From e584998159a843e84c9e9717c1c193bf82c4a855 Mon Sep 17 00:00:00 2001
From: Bart Van Assche <bvanass...@acm.org>
Date: Fri, 15 May 2015 18:49:22 +0200
Subject: [PATCH] CHANGES: HP-UX on ia64: Really fix large fd set
 implementation

---
 snmplib/large_fd_set.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/snmplib/large_fd_set.c b/snmplib/large_fd_set.c
index 4680d44..f996559 100644
--- a/snmplib/large_fd_set.c
+++ b/snmplib/large_fd_set.c
@@ -85,29 +85,38 @@ netsnmp_large_fd_is_set(SOCKET fd, netsnmp_large_fd_set * fdset)
 
 /*
  * Recent versions of glibc trigger abort() if FD_SET(), FD_CLR() or
- * FD_ISSET() is invoked with n >= FD_SETSIZE. Hence these replacement macros.
- * Since NFDBITS != 8 * sizeof(fd_set.fds_bits[0]) for HP-UX on ia64, avoid
- * using NFDBITS.
+ * FD_ISSET() is invoked with n >= FD_SETSIZE. Hence these replacement
+ * functions. Since NFDBITS != 8 * sizeof(fd_set.fds_bits[0]) for at least
+ * HP-UX on ia64, be careful with NFDBITS.
  */
 NETSNMP_STATIC_INLINE void LFD_SET(unsigned n, fd_set *p)
 {
     enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
 
-    p->fds_bits[n / nfdbits] |= (1ULL << (n % nfdbits));
+    if (nfdbits == NFDBITS)
+        p->fds_bits[n / nfdbits] |= (1ULL << (n % nfdbits));
+    else
+        FD_SET(n, p);
 }
 
 NETSNMP_STATIC_INLINE void LFD_CLR(unsigned n, fd_set *p)
 {
     enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
 
-    p->fds_bits[n / nfdbits] &= ~(1ULL << (n % nfdbits));
+    if (nfdbits == NFDBITS)
+        p->fds_bits[n / nfdbits] &= ~(1ULL << (n % nfdbits));
+    else
+        FD_CLR(n, p);
 }
 
 NETSNMP_STATIC_INLINE unsigned LFD_ISSET(unsigned n, const fd_set *p)
 {
     enum { nfdbits = 8 * sizeof(p->fds_bits[0]) };
 
-    return (p->fds_bits[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
+    if (nfdbits == NFDBITS)
+        return (p->fds_bits[n / nfdbits] & (1ULL << (n % nfdbits))) != 0;
+    else
+        return FD_ISSET(n, p) != 0;
 }
 
 void
-- 
2.1.4

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to