[SNMP4J] Agent 1.0 beta 2 SET command locked
Frank Fock
fock at agentpp.com
Fri May 19 20:00:01 CEST 2006
Hi Matthieu,
Sorry, this is a bug/shortcoming in MOScalar.
In the methods MOScalar.prepare and MOScalar.undo
the phase should be set to "complete".
This code would be correct:
public void prepare(SubRequest request) {
RequestStatus status = request.getStatus();
if (access.isAccessibleForWrite()) {
VariableBinding vb = request.getVariableBinding();
if (vb.getVariable().getSyntax() != getValue().getSyntax()) {
status.setErrorStatus(SnmpConstants.SNMP_ERROR_WRONG_TYPE);
return;
}
int valueOK = isValueOK(request);
status.setErrorStatus(valueOK);
status.setPhaseComplete(true);
}
else {
status.setErrorStatus(SnmpConstants.SNMP_ERROR_NOT_WRITEABLE);
}
}
public void commit(SubRequest request) {
RequestStatus status = request.getStatus();
VariableBinding vb = request.getVariableBinding();
request.setUndoValue(getValue());
setValue(vb.getVariable());
status.setPhaseComplete(true);
}
public void undo(SubRequest request) {
RequestStatus status = request.getStatus();
if ((request.getUndoValue() != null) &&
(request.getUndoValue() instanceof Variable)) {
int errorStatus = setValue((Variable)request.getUndoValue());
status.setErrorStatus(errorStatus);
status.setPhaseComplete(true);
}
else {
status.setErrorStatus(SnmpConstants.SNMP_ERROR_UNDO_FAILED);
}
}
I will upload a fixed version on Monday!
Best regards,
Frank
Matthieu Casanova wrote:
> Hi, I switched from agent 1.0 beta 1 to beta 2.
> I have in my server a MoScalar on which I'm doing some SETs. Of course it
> was working with beta 1, but not anymore with beta 2.
> In fact during the process it is locked at line 632 of CommandProcessor
> during the SetHandler.prepare()
> The prepare method is the default of MOScalar.
> the errorStatus found at line 126 of MOScalar is 0 so I think it means that
> it's all right
> But in the RequestStatus class in method setErrorStatus()
> there are those lines
>
> boolean error = (errorStatus != SnmpConstants.SNMP_ERROR_SUCCESS);
> setPhaseComplete(error);
>
> so if the error status was 0 ( SnmpConstants.SNMP_ERROR_SUCCESS )
> this means that the phase is not complete.
> But it seems the request is not processed again, and the MOScalar remains
> locked because nothing calls unlock.
> Did I forgot something ?
>
> Matthieu
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j
--
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com
More information about the SNMP4J
mailing list