in reply to Advice on a CGI script
Consider two people hitting this code at almost the same time. Since the code is being multitasked, it is possible that one script will zero out the counter right before the next one reads it... Something like:
See File Locking for a tutorial on using flock to avoid this.A: read counter Data: linux:700 windows:6 A: zero out counter Data: -------------------- B: read counter Data: linux:0 windows:0 A: write out counter Data: linux:701 windows:6 B: zero out counter Data: -------------------- B: write counter Data: linux:1 windows:0 <-- Doh!
-Blake
|
|---|