From: Vincent Bernat Date: Tue, 23 Mar 2010 14:32:29 +0000 (+0100) Subject: Fix hang issue in select() loop with SNMP. X-Git-Tag: 0.5.1~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=630b4134e8ca84f205e12d8690182a216254f403;p=thirdparty%2Flldpd.git Fix hang issue in select() loop with SNMP. 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. --- diff --git a/src/lldpd.c b/src/lldpd.c index 05a840ef..72f2994e 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -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);