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

Claus Klein claus.klein at arcormail.de
Thu Dec 11 22:55:39 CET 2014


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






More information about the AGENTPP mailing list