From: Mozejko, MarcinX Date: Tue, 27 Feb 2018 09:54:13 +0000 (+0000) Subject: SNMP Agent plugin: Fix - not every OID is unregistered from snmp table X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=1df1a595017f4adfd159f7a923a721a2e83fd682;p=collectd.git SNMP Agent plugin: Fix - not every OID is unregistered from snmp table Problem occures when a metric has more than one OID assigned. Then, during the table unregistration, plugin thinks that there are some OIDs left in the table and keeps index keys also registered. It's because plugin registers all the OIDs for the particular metric, but unregisters only the first one which is wrong. Change-Id: I6daae1ceeebf30b98f22075940b29936ee3d110d Signed-off-by: Mozejko, MarcinX --- diff --git a/src/snmp_agent.c b/src/snmp_agent.c index bbc4dcd0..8f556d85 100644 --- a/src/snmp_agent.c +++ b/src/snmp_agent.c @@ -671,15 +671,20 @@ static void snmp_agent_table_data_remove(data_definition_t *dd, pthread_mutex_lock(&g_agent->agentx_lock); + int reg_oids = -1; /* Number of registered oids for given instance */ + for (size_t i = 0; i < dd->oids_len; i++) { if (td->index_oid.oid_len) snmp_agent_unregister_oid_index(&dd->oids[i], *index); else snmp_agent_unregister_oid_string(&dd->oids[i], index_oid); + + reg_oids = + snmp_agent_update_instance_oids(td->instance_oids, index_oid, -1); } /* Checking if any metrics are left registered */ - if (snmp_agent_update_instance_oids(td->instance_oids, index_oid, -1) > 0) { + if (reg_oids != 0) { pthread_mutex_unlock(&g_agent->agentx_lock); return; }