|
Posted by trlists on 03/25/05 05:26
On 24 Mar 2005 Joshua Beall wrote:
> I realized that this sort of problem would always exist unless I had some
> sort of semaphore mechanism. Once a user has *started* a transaction, they
> need to be prevented from initiating a second transaction until the first
> transaction has been completed.
Why not simply store some kind of user ID and a timestamp for the
transaction start time in a database. Every time a new transaction is
started check the database, if there is another one in process, give an
appropriate error. When the transaction completes delete the record.
The hole in this of course is transactions that start and never finish.
That's why I suggest a timestamp -- you can use it to check how long
it's been since the previous transaction started, and ignore it if
that's over some threshold (for example, if the previous transaction
was stated a minute ago and a normal transaction takes 5 seconds, you
can be pretty sure). And you can run a cron job to periodically sweep
the database and remove old transactions that never completed.
--
Tom
Navigation:
[Reply to this message]
|