On Thu, Sep 25, 2008 at 09:36:02PM +0100, Hans wrote: > A form lets a user add a row of data, and this row is identified by > an id rownumber, which is written as a PTV, and incremented by 1 with > every form submission. > > Now two (or more) users submit this form at the same time more or > less exactly (less than 2 seconds of each other). How can it be > guaranteed that each row will be allocated a correctly increased > rownumber?
You want a transaction lock -- the same way that PmWiki does it. Before doing any processing that might modify pages, call Lock(2). If you're reading from a page for a value that will be later be used as part of an update, then you want to Lock(2) prior to the read, not only during the write. This way other processes that might be doing read-process-update will block prior to their reads, giving the current process a chance to finish doing its updates. Pm _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel