Re: how to lock a block of php codes
- From: "ED" <ed@xxxxxxxxxxx>
- Date: Wed, 25 Oct 2006 10:45:15 GMT
"kelvin" <kelvin_gl@xxxxxxxxxxxx> wrote in message
news:1161738745.665437.168230@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
bob.chatman@xxxxxxxxx wrote:
are you talking about 2 users calling a page at the same time?
Exactly.
A little more information:
The php page is actually called by PayPal IPN.
It works just fine in most case.
But a few times PayPal will call this page twice at the same time.
And it causes bugs. Because the first time information hasn't been
insert into the database, the second call happens.
So I want to find a method to avoid this.
Thank you a lot,
Kelvin
kelvin wrote:
Hi,
How to avoid one php page be called by 2 at the same time?
How to lock a block of codes in php?
something like
mutex.Lock
//...............
One service one time
//................
mutex.Unlock
Any way to do this?
Thank you,
Kelvin
Hi Kelvin,
I generally use a text file as a lock so:
$fp = @fopen("lock.txt", "w+"); //open lock file
if ($fp && (flock($fp, LOCK_EX))) {//place an exclusive lock on the file
//do stuff
@fclose($fp); //release Lock
cheers
ED
.
- Follow-Ups:
- Re: how to lock a block of php codes
- From: peter
- Re: how to lock a block of php codes
- References:
- how to lock a block of php codes
- From: kelvin
- Re: how to lock a block of php codes
- From: bob.chatman@xxxxxxxxx
- Re: how to lock a block of php codes
- From: kelvin
- how to lock a block of php codes
- Prev by Date: Slow response using ODBC/VFP
- Next by Date: Re: how to lock a block of php codes
- Previous by thread: Re: how to lock a block of php codes
- Next by thread: Re: how to lock a block of php codes
- Index(es):
Relevant Pages
|