Jim Gallacher
jpg at jgassociates.ca
Fri Aug 11 12:27:55 EDT 2006
Norman Tindall wrote: > Hello Jim, > > I describe you the session locking mechanizm as i see, > correct me if i am wrong. > > As to lock subroutine in _apache we passing: > 1 - server object > 2 - session_id > From this i can tell that in fact locked session_ids (session > data locked indirect) > > +----------------------------------------------+---------------------+ > | session_id | status | serv that aq lock | > +----------------------------------------------+---------------------+ > | 5540fda192a40b4acd084decdb6f66ed | locked | thread 1 server id > | 9ec0c48867bff638b7a790c314ed52ff | locked | thread 4 server id > | .. .. .. .. .. .. .. .. .. .. .. .. .... .... .... .... .. > +------------------------------------------------------------------- > ^ | ^ | ^ | > 1)Lock | | | 4)Lock | 7)Lock | | > | 3)release | | | 9) release > | | | 6)release | | > +-----------+ +--------------------+ +---------------- > | thread 1 | | thread 2 | | thread 3 also > +-----------+ +----------- trying to aquire > | aquired lock | trying to > on 5540fd.. aquire lock on | > sess_id 5540fd.. but blocked | > until thread 1 releases lock | 8) write > | \ 5) Write | > 2) Write | +--------------------------------------+ | > ----->| session data (in file or mysql) | <--- > +--------------------------------------+ > > Thread 1 locking sess_id, making manipulation with session > data, writing it to file (or DBD or MySQL), release lock, > then thread 2 locking that sess_id and so on.. > So in fact locked session_id, while session locked indirect, > because no manipulation can be made before lock aquire and so > manipulation with same sess_id data is quened across threads. > > And if i right, my module from previous letter will work with > lock. > > Am i right? Yes, although there may be some additional locking going on for the actual data store. For example the current implementation of of DbmSession serializes access to the dbm file using a global lock so there are actually 2 locks involved - one for the session (represented by the session id) and one for the dbm file. The global lock for the file ensures the integrity of the data store, so even if the user elects to turn off session locking the dbm file will not be corrupted, even if the data for individual sessions is not valid. FileSession uses a similar trick. Jim
|