buffering, Rlock() and FLOCK()  
Author Message
Aleniko29139





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

Hi;

I think I don't understand the concept of buffering. Can someone explain the following behavior

I have a form which uses opt. table buffering. While that form is open by a user, I manually rlock() one of the records. Then, I ask the user to change the same record.
The change, including the =tableupdate() goes through fine.
I try the same with FLOCK(), and the change still goes through fine.

Shouldn't FLOCK prevent the user from comiting a change

thanks.


Visual FoxPro2  
 
 
CetinBasoz





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

Why It's the same user (session) doing rlock()/flock() and tableupdate(), no If I didin't understand it wrong, tableupdate() needs a lock during write and you already have it.
 
 
Aleniko





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

No, its a different user. The USER opens up the form. I go into VFP, use the file, go to the recno the user is on, issue rlock() or Flock().

 
 
CetinBasoz





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

I still do not understand clearly I think. Other user locked and you can do replace Else that's what I'd expect.
 
 
Aleniko





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

OK - let me explain again:

User A opens up an application and goes into a form. The form has a table that is open in an optimistic table buffering.

At the same time, user B (Which happens to be me) opens up VFP, and issues the following commands:

use tablename
flock()
(Which returns .T.)

Then, user A uses the form to apply some changes to a record in the table and issues a tableupdate().

Isn't FLOCK suppose to lock the file so other users can't do changes

Thanks again.

 
 
CetinBasoz





PostPosted: Visual FoxPro General, buffering, Rlock() and FLOCK() Top

Yes it's supposed to lock the file so other user can't do changes. Can they Do you have a reproducing code

Here is a simple test file. Try it, I couldn't update (flock() did its job):

Public oForm

oForm = Createobject('myForm')

oForm.Show

Define Class myForm As Form

DataSession = 2

Height = 550

Add Object myGrid As Grid With Height = 440

Add Object txtUpdate1 As TextBox With ControlSource = 'customer.company', Top=450, Left = 10

Add Object txtUpdate2 As TextBox With ControlSource = 'customer.contact', Top=450, Left = 200

Add Object cmdUpdate As CommandButton With Caption="Update",Top=500

Procedure Load

Set Multilocks On

Use (_samples+'data\customer')

CursorSetProp("Buffering",5,'Customer')

Endproc

Procedure myGrid.AfterRowColChange(nIndex)

Thisform.Refresh

Endproc

Procedure cmdUpdate.Click

SET REPROCESS TO 1

Messagebox("Update"+Iif(!Tableupdate(2,.T.,'customer'), " not","")+" successfull.")

Endproc

Enddefine

Run this within a VFP session. Launch another session to mimic multiuser and flock() customer table. Try to update in first one.