[AGENT++] agentX++ interoperability with NET-SNMP version 5.7.3.rc1

Claus Klein claus.klein at arcormail.de
Mon Nov 24 22:28:05 CET 2014


Hi Frank,

On 24.11.2014, at 00:32, Frank Fock <fock at agentpp.com> wrote:

> So, everything is working as expected, isn't it?

No, there are still problems in case of index allocation errors at subagent example!
Sorry about the trouble, but I found the error. ;-))

The vbs is double deleted; see code snipped below.

Dit you ever run 2 subagent demoes at the same time working with one master agent?
If not, try it …, I would expect to see 6 rows at the ifTable, but there are no more then 3.

Best regards,
Claus

///////////////////////////////////////////////////////////////////////////////////////////////

void SubAgentXMib::process_response(AgentXRequest* r)
{
// ….

		case AGENTX_INDEXALLOCATE_PDU:
		case AGENTX_INDEXDEALLOCATE_PDU: {
			int type = pending->get_agentx_type();
			queue->remove(pending);
			queue->unlock();
			pendingMessagesLock.lock();
			AgentXPendingMessage* m = get_pending_message(response->get_packet_id());
			if (m) pendingMessages.remove(m);
			pendingMessagesLock.unlock();
			int sz = response->get_vb_count();
			Vbx* vbs = new Vbx[sz];			>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
			response->get_vblist(vbs, sz);
			if (m) {
				LOG_BEGIN(loggerModuleName, DEBUG_LOG | 1);
				LOG("SubAgentXMib: index (de)allocate response (err)(errind)(values..)");
				LOG(response->get_error_status());
				LOG(response->get_error_index());
				LOG(m->receiver->key()->get_printable());
				for (int i=0; i<sz; i++) {
					LOG(vbs[i].get_printable_oid());
					LOG(vbs[i].get_printable_value());
				}
				LOG_END;
				if (type == AGENTX_INDEXALLOCATE_PDU)
					index_allocated(response->get_error_status(),
									response->get_error_index(),
									vbs, sz, m->receiver,
									response->get_packet_id(),
									m->row_index);
				else
					index_deallocated(response->get_error_status(),
									  response->get_error_index(),
									  vbs, sz, m->receiver,
									  response->get_packet_id(),
									  m->row_index);
				delete m;
			}
			else {
				if (type == AGENTX_INDEXALLOCATE_PDU)
					index_allocated(response->get_error_status(),
									response->get_error_index(),
									vbs, sz, 0, 0, 0);
				else
					index_deallocated(response->get_error_status(),
									  response->get_error_index(),
									  vbs, sz, 0, 0, 0);
			}
//TODO already freeed at index_allocated() in case of error!
			delete[] vbs;	//FIXME subagent(95249,0x1005c1000) malloc: *** error for object 0x1006153a0: pointer being freed was not allocated
			break;
		}
// …
}

void AgentXSharedTable::index_allocated(const Oidx& ind, int err, int errind,
                                        Vbx* vbs, u_int vbs_length)
{
	if (err == AGENTX_OK) {
		switch (indexStrategy) {
			case anyNonAllocatedSubIndex: {
				Vbx* orig_vbs = create_index_vbs(ind);
				if (!orig_vbs) return;
				for (unsigned int i=0; i<index_len; i++) {
					backReference->get_index_registry()->
					allocate(backReference->get_session()->get_id(),
							 orig_vbs[i], false);
				}
				delete[] orig_vbs;
				break;
			}
			default: break;	//TODO check this! ck
		}
		// default behavior is to add the row when allocation succeeded
		add_row(ind);
	}
	else {
		switch (indexStrategy) {
			case firstSubIndexOnly:
			case anyNonAllocatedSubIndex: {
				if (!vbs) return;
				for (unsigned int i=0; i<vbs_length; i++) {
					backReference->get_index_registry()->
					release(backReference->get_session()->get_id(),
							vbs[i], false);
				}
				//FIXME why? delete[] vbs;	<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
				break;
			}
			default: break;	//TODO check this! ck
		}
	}
}



More information about the AGENTPP mailing list