]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Fix hang issue in select() loop with SNMP.
authorVincent Bernat <bernat@luffy.cx>
Tue, 23 Mar 2010 14:32:29 +0000 (15:32 +0100)
committerVincent Bernat <bernat@luffy.cx>
Tue, 23 Mar 2010 14:33:32 +0000 (15:33 +0100)
The last argument of snmp_select_info() should be set to 0 and should
be checked to be 0 after call. Otherwise, the timeval argument should
be ignored.

src/lldpd.c

index 05a840eff1a8b9ef8e9706c6616b71f16314c9d3..72f2994e27c2d666c204539f5633d2894d016240 100644 (file)
@@ -508,8 +508,8 @@ lldpd_recv_all(struct lldpd *cfg)
        fd_set rfds;
        struct timeval tv;
 #ifdef USE_SNMP
-       int fakeblock = 0;
-       struct timeval *tvp = &tv;
+       struct timeval snmptv;
+       int snmpblock = 0;
 #endif
        int rc, nfds, n;
        char *buffer;
@@ -545,8 +545,13 @@ lldpd_recv_all(struct lldpd *cfg)
                }
                
 #ifdef USE_SNMP
-               if (cfg->g_snmp)
-                       snmp_select_info(&nfds, &rfds, tvp, &fakeblock);
+               if (cfg->g_snmp) {
+                       snmpblock = 0;
+                       memcpy(&snmptv, &tv, sizeof(struct timeval));
+                       snmp_select_info(&nfds, &rfds, &snmptv, &snmpblock);
+                       if (snmpblock == 0)
+                               memcpy(&tv, &snmptv, sizeof(struct timeval));
+               }
 #endif /* USE_SNMP */
                if (nfds == -1) {
                        sleep(cfg->g_delay);