Stop multiple sessions accessing the same file simultaneously

Posted by Pablo on Stack Overflow See other posts from Stack Overflow or by Pablo
Published on 2010-06-14T10:59:50Z Indexed on 2010/06/14 11:02 UTC
Read the original article Hit count: 403

Filed under:
|

Is it possible to lock a file to stop it being opened while GD library is accessing it?

What I am looking to achieve is similar to a database 'serialzable' level of isolation... I want to ensure that only one session/user can access an image at a time to stop a 'dirty read'.

May application allows users to add an image of choice to a bigger image.

for example

  • the big image is empty
  • Raj & Janet upload their images
  • Raj's session opens the big image.
  • 1 ms later Janet's session opens the big image.
  • Raj's session add's his image and saves the big image
  • 1 ms later Janet's session adds his image and saves its version of the big image.
  • As a result Raj's image is not in the final image as Janet's version overwrote it.

I hope that makes it clear enough.

© Stack Overflow or respective owner

Related posts about php

Related posts about gd