strange persistence problem
Dave Mason
dmason____transat-tech.com
Sat Sep 28 00:28:56 CEST 2002
Hi Frank,
I think I tracked this down. I use this particular object
programmatically (my speller doesnt seem to know how to handle that any
better than I do), like this:
unsigned long seqNum = 0ul;
while (running) {
do some stuff, incremement seqNum
wsSeqNum::instance->set_value(seqNum);
}
If you look in mib.cpp for MibLeaf::set_value(const unsigned long l),
the first line is
set_syntax(sNMP_SYNTAX_INT32);
This apparently changes the syntax to signed integer, and it gets
written to persistent storage that way. Later, I get the error below
when I try to read this back into an unsigned integer. I believe this
should be
set_syntax(sNMP_SYNTAX_GAUGE32);
or something similar (UINT32).
Regards,
Dave
Frank Fock wrote:
> Hi Dave,
>
> Are you sure that the syntax was Gauge32 when the object
> has been written to disk?
>
> May be the syntax had been changed accidentally by calling
> replace_value?
>
> The syntax is not checked when data is loaded, so if the
> syntax of an object changes, one has to write conversion
> routines to be able to use the old configuration files.
>
> Hope this helps.
>
> Best regards,
> Frank
>
> Dave Mason wrote:
>
>> Hi,
>> I have a problem where the syntax of an object appears to change
>> after the persistence data is read in. Here is a code fragment from
>> agent.cpp. In the MIB, wsSeqNum has SYNTAX Unsigned32, DEFVAL 0.
>> AgentGen Pro appears to translate this to Gauge32.
>>
>> // add supported objects
>> init(*mib);
>> // add user modules
>> module_init(mib);
>>
>> int rc;
>> unsigned long seqNum;
>> rc = wsSeqNum::instance->get_value(seqNum);
>> // load persitent objects from disk
>> mib->init();
>> rc = wsSeqNum::instance->get_value(seqNum);
>>
>> The first get_value works fine, leaving seqNum with the initial
>> default value of 0. The return code rc is 0. However, after the
>> mib->init(), the same get_value fails because it now thinks the
>> object syntax is a signed integer. The return code is -10.
>> Interestingly enough, the second get_value works if I delete the
>> persistence data files. Any ideas?
>>
>> Regards,
>> Dave
>>
>>
More information about the AGENTPP
mailing list