

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://net-snmp.sourceforge.io/wiki/index.php?action=history&amp;feed=atom&amp;title=Prevent_two_clients_from_making_conflicting_updates</id>
		<title>Prevent two clients from making conflicting updates - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://net-snmp.sourceforge.io/wiki/index.php?action=history&amp;feed=atom&amp;title=Prevent_two_clients_from_making_conflicting_updates"/>
		<link rel="alternate" type="text/html" href="https://net-snmp.sourceforge.io/wiki/index.php?title=Prevent_two_clients_from_making_conflicting_updates&amp;action=history"/>
		<updated>2026-04-28T19:05:00Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.3</generator>

	<entry>
		<id>https://net-snmp.sourceforge.io/wiki/index.php?title=Prevent_two_clients_from_making_conflicting_updates&amp;diff=3133&amp;oldid=prev</id>
		<title>Dts12 at 08:32, 17 October 2007</title>
		<link rel="alternate" type="text/html" href="https://net-snmp.sourceforge.io/wiki/index.php?title=Prevent_two_clients_from_making_conflicting_updates&amp;diff=3133&amp;oldid=prev"/>
				<updated>2007-10-17T08:32:32Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{GoodAnswer}}&lt;br /&gt;
&lt;br /&gt;
== Question ==&lt;br /&gt;
&lt;br /&gt;
When two applications try to update a MIB at same time, it’s possible that&lt;br /&gt;
one application will rewrite the data that other application just wrote.&lt;br /&gt;
&lt;br /&gt;
How can I guarantee that two applications can’t update the same node at the same time.&lt;br /&gt;
&lt;br /&gt;
Can I implement a kind of semaphore or implement a synchronization of write operation?&lt;br /&gt;
&lt;br /&gt;
== Answer ==&lt;br /&gt;
&lt;br /&gt;
The usual SNMP mechanism for implementing this would be a MIB &amp;#039;&amp;lt;CODE&amp;gt;TestAndIncr&amp;lt;/CODE&amp;gt;&amp;#039;&lt;br /&gt;
object.   Each application would retrieve the contents of the table together with&lt;br /&gt;
this semaphore value  (as a single SNMP request).   They would each then issue a&lt;br /&gt;
SET request, containing the new table values and this same semaphore value&lt;br /&gt;
(again, as a single SNMP request).&lt;br /&gt;
&lt;br /&gt;
The first client would be providing the same semaphore value as the one read,&lt;br /&gt;
so the SET request would succeed (incrementing the internal semaphore value).&lt;br /&gt;
The second client would now be providing an out-of-date semaphore value,&lt;br /&gt;
so the SET request would be rejected.&lt;br /&gt;
&lt;br /&gt;
There is a helper routine&lt;br /&gt;
&lt;br /&gt;
    int  netsnmp_register_watched_spinlock(&lt;br /&gt;
                               netsnmp_handler_registration *reginfo, int *spinlock);&lt;br /&gt;
&lt;br /&gt;
to implement just such a semaphore object.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:agent]]&lt;/div&gt;</summary>
		<author><name>Dts12</name></author>	</entry>

	</feed>