[AGENT++] Patch to fix Mib::cleanup() and prevent possible deadlock

Frank Fock fock at agentpp.com
Fri Dec 12 00:53:36 CET 2014


Hi Claus,

 From my point of view your patch does not fix the root cause.
Normally, a  Mib::cleanup should never get into a deadlock
because it first locks the Mib and then single objects.
Since all the other AGENT++ and AgentX++ code  uses the
same locking scheme, a dead lock should not happen.

If it happens though, then some other code does not implement
the locking scheme properly. So I will have a look at the
timeout thing in process_request() which seems to be
prerequisite for the deadlock and therefore I might be able
to find the root cause there.

Best regards,
Frank


Am 11.12.2014 22:55, schrieb Claus Klein:
> Hi Frank,
>
> I have still problems with the not working cleanup() function.
> I use it like this at the agentx subagent main loop:
>
> 	do {
> 		retries = 0;
> 		while ((continueWork) && (!mib->get_agentx()->quit())) {
>
> 			req = reqList->receive(20000);	// ms
>
> 			if (req) {
> 				mib->process_request(req);
> 			} else {
> 				mib->ping_master();
>
>
> 				//NOTE possible deadlock at cleanup() -> lock_mib() after get request timeout with Mib::process_request() -> lock_mib()!
> 				reqList->timeout_set_requests();	// does only help for set request timeout!
> 				mib->cleanup();
>
> 				// here we add or remove rows at shared ifTable
> 				test_index_allocation();
> 			}
> 		}
>
> 		// Make sure that all pending set requests which may
> 		// have locked any resources are terminated and resources
> 		// are freed before connection to master is reestablished.
> 		reqList->terminate_set_requests();
>
> 		//NOTE this calls may end in a deadlock after row destroy timeout or set request timeout! ck
> 		mib->cleanup();
> 		mib->save_all();
>
> 		while ((continueWork) && (retries++ < 10) && (!mib->init())) {
> 			Thread::sleep(retries * 1000);    // ms (up to 10 sec)
> 		}
> 	} while ((continueWork) && (retries < 10));
>
>
> The current version does nothing, but often it ends at a deadlock.
> I have tried to fix it and attach my patch.
>
> With regards,
> Claus
>
>
>
>
> _______________________________________________
> AGENTPP mailing list
> AGENTPP at agentpp.org
> https://oosnmp.net/mailman/listinfo/agentpp

-- 
---
AGENT++
Maximilian-Kolbe-Str. 10
73257 Koengen, Germany
https://agentpp.com
Phone: +49 7024 8688230
Fax:   +49 7024 8688231



More information about the AGENTPP mailing list