Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Flock() and unlock
Message
 
 
To
25/11/1997 11:28:43
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00062174
Message ID:
00062213
Views:
20
>Hi everybody!
>
>I met with a feature of VFP! I don't know if it is knonw for everyone, but it was suprising for me.
>
>use mytable alias myalias1 in 0
>use mytable alias myalias2 again in 0
>
>flock("myalias1") && it locks MYTABLE
>flock("myalias2") && it also locks MYTABLE
>
>unlock in myalias1 && it removes lock from MYTABLE
> && -> myalias2 is NOT LOCKOED anylonger
>
>So, locking a table in an alias lock the table phisically.
>Every alias, referencing to this table can use this table as a locked table, but can FLOCK()s it.
>
>UNLOCKing any alias, referencing to this table will remove the locking from that table. (it means all alias referencing to this table lose locked state of this table)
>I thought that VFP has a lock count of every table, and only remove the lock from a table, if lock count is 0 again (flock increments, unlock decrement the table lock counter). But it is not ...
>
>It is very similar to that behaviour, as use command with noupdate clause. If the first use of a table contains noupdate clause, any subsequent use of this table will open in read only mode thais table. It is independent from datasessions. (I read it in UT, and it gave me the idea testing this lock behaviour.)
>I read in dev guide of VFP, that VFP use only one file handle for all aliases of a certain table. I guess this is the explanation of this behaviour.
>
>So, any comment?
>
>BB

You are trying this on the same machine or datasession. On a networked system (or in Win95 start 2 sessions of VFP, or use 2 private data sessions), you could open the same table twice and issue FLOCK() -- returns .T. Go to another machine/datasession/VFPsession and open the same table twice again. FLOCK() here will always return .F. on the table you locked on the first machine regardless of the alias you use. In the same data session, FLOCK on a table means all instances of that table have FLOCK() = .t. Make sure you issue SET EXCLUSIVE OFF before opening any databases/tables. Only 1 entity (user/machine) can hold a FileLock at any one time.
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform