[V4RB] OPEN/Close trick?

Keith DeLong delong at redcort.com
Tue Aug 3 09:22:00 CDT 2004


Hi Karen,
The 'trick' stopped being really useful with the release of Apple's OS X.

In OS 9 and Windows, attempting to open an already open file throws an
otherwise harmless OS error that you can check. This was the basis of the
trick. It allowed you to open, use and close the data file with multiple
users. All users simply do open attempts in a loop until the file is
available. 

With the advent of OS X (with its Unix underpinnings), a file will happily
open multiple times with no error thrown by the OS. However, as soon as a
any one of the multiple users of the file attempts to write to the file, you
get a nasty -61 system error that basically ruins all open connections until
all of the applications are quit and restarted. I tried to work around this
for months with no real success.

Your options are (1) to set up an external lock file (there's a reference to
a useful Apple tech note in the Valentina archives) that flags the data file
as available or not. (2) To use Vserver, or (3) to design a network protocol
where all clients send data reads and writes via sockets to a single
instance of V4RB running as a server app.

I was never able to get a satisfactory lock file solution after several
months of work. It works well, just not 100% of the time. Since VServer
wasn't near ready last summer when I needed a solution, I wrote the custom
protocol. While it works very well, it proved to be a tremendous amount of
work for me. But in the end I have complete control and a proven V4RB 1.1
platform that meets my current needs. So I guess it was worth the effort.

But given Ruslan's progress with Vserver and the 2.0 platform, I think
moving to Vserver will be your best bet today.

HTH,

Keith DeLong

> I can't seem to get it to work.
> If the DB is in use on the First try I get error -61. on all subsequent
> retries Get Error 524 even after the other client closes the db.
> 
> I must be missing something
> 
> My attempt to open routine in the VDataBase subclass is :
> 
> Function TryToOpen() As Integer
>   Dim Num, err as integer ' Put in so I could see easily them in the
> debugger
> 
>   isOpen = Super.Open(Location)
> 
>   err = me.ErrNumber
>   If IsOpen AND err = 0 Then ' see if can write to it
> 
>      Num = me.SqlExecute("UPDATE Dummy SET F = 2 WHERE RecID = 1")
>      err = me.ErrNumber
>      if err <> 0 Then
>         me.Close
>         isOpen = False
>      End if
> 
>   End if
> 
>   Return err
> End Function
> 
> What am I doing wrong?
> 
> This is on OSX BTW . Should this trick work on OS9, and Win2K? I need
> it to!
> 
> -Karen
> 
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina
> 



More information about the Valentina mailing list