On 30/10/2007, andre robalo <[EMAIL PROTECTED]> wrote:
> In all examples i saw, the use of a spin lock object is only by scalar
> objects.
> I have a situation where I need to use this concept, but applied to a table.

A spin lock is typically *implemented* as a scalar object,
but it's perfectly common to use that (scalar) spin lock to protect a table.

Just retrieve the scalar spinlock value at the same time as the table
contents that you are interested in - and then include the (scalar)
spinlock assignment as part of the update request:

    $   snmpget localhost   snmpSetSerialNo.0   ifAdminStatus.2
    snmpSetSerialNo.0 = 12345
    ifAdminStatus.2= up(1)

    $  snmpset localhost   snmpSetSerialNo.0 i 12345 ifAdminStatus.2 i 2
    snmpSetSerialNo.0 = 12345
    ifAdminStatus.2= down(2)


You could implement the spinlock as a column object, but there's
typically no real need.


> In this situation, i would have a table column that is a spinlock
> (testAndIncr object).
>
> My first question is : Is this possible ?

Yes - it is possible.
You probably can't use the spinlock helper, which is designed
to implement a scalar object.   But there's nothing special about
the code.  You could perfectly easily implement this as an
integer column object.
   The only special thing about a TestAndIncr object, is the check
that the assigned value matches the current one, and incrementing
this value at the end of a successful SET request.


> Am I doing anything wrong in my code?

In general, this looks mostly OK.
Two things spring out though:



>         case MODE_SET_ACTION:
>                                         data =
> netsnmp_table_data_set_find_column(rowData,COLUMN_SPINLOCK);
>                                         if(data != NULL)
>                                                 data->data.voidp ++;

Shouldn't you be incrementing the value that voidp points to,
rather than the pointer itself?

>                                         else
>                                                 data->data.voidp = 0;

More seriously, if data is NULL, then you can't access data->data!

Dave

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users

Reply via email to