Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Section 'Locking Data' in the VFP7 Help
Message
De
27/08/2002 15:41:13
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro Documentation de produit
Divers
Thread ID:
00693991
Message ID:
00694209
Vues:
13
Jim,

I have a bit of a conundrum with this FILE locking and EXCLUSIVE use business...

The easier stuff first though. I believe that we can agree tht this "semaphore" protocol must be within the OS and/or its file system [i.e. NOT something strictly internal to VFP].
This seems obvious to me because different workstations' VFPs are known to not communicate with each other. So the only way that locking can be controlled and effective is if the OS or file system is the "master controller" of this information.

Now for the troubling observations:
On system A I USE a table in EXCLUSIVE mode. The table resides on C: of system A.

On system B I d-click the same table (C: of A system), VFP starts as expected and then I get a 'file access denied' error. I stop VFP on system B at that point.

On system B I then rt-click the same table and then tell the system to open the table with EXCEL. Excel starts as expected and then I get a 'file access denied'. I exit Excel on system B.

Back on system A I USE the table to close it, then I USE it in SHARED mode, then I FLOCK() and it returns .T.

On system B I then d-click the same table and get 'file access denied' after VFP starts up on system B. I stop VFP on system B at that point.

On system B I then rt-click on the table name in Explorer and tell it to start Excel for the file. Excel starts and I get the error message "'xxxx.dbf' cannot be accessed. The file may be read-only or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding.

This all leads me to conclude that:
1) The locking controls are "outside" of VFP;
2) An EXCLUSIVE and a FLOCK() are so similar in result as to be the same mechanism.

What are your conclusions for the above?

cheers

>Jim,
>
>>I would certainly agree with you if I was sure of exactly what a "file lock" is. My GUESS on the subject is that a "file lock" is a totally different mechanism than a record lock and that there is a good likelihood that it is the same mechanism that the operating system (file system) uses across all applications when it wants to prevent access of the file by others.
>>Can you please clarify the situation?
>
>A file lock is similar to having a record lock on all the records simultaneously. A file lock prevents any one from getting a file lock or record lock on any record within the table. It does not prevent others from opening the table or reading the data, also one can obtain a file lock even if others have the table open as long as they have no record locks or file lock. Whereas EXSCLUSIVE use prevents anyone from opening the table and is denied if anyone has the table open.
>
>As to the exact mechanism VFP uses to secure these types of locks I don't know the details except that the locks (file and record locks are actually semiphore locks as VFP is locking a location on the disk that is offset from the actual location of the record or file (this offset is one of the reasons for the 2 GB limit on file size). I believe that exclusive use is accomplished by requesting esxclusive access from the OS.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform