I know it sounds like a programming question but it's actually not. Bear with me please:
I have a customer who is experiencing a strange issue that I cannot explain: a program uses a file on a shared SMB drive (Windows 2008R2 server) open in shared mode.
Before performing an update inside the file, the program will lock specific potions using LockFile, read the data, write the required changes to these portions and then unlock them.
This is done to ensure that several instances of the same program can overwrite each other's changes.
In my customer case, this program (which behaved perfectly well for years in all other locations) succeeds in locking the file but the subsequent call to ReadFile on the same handle fails and GetlastError returns error 64 The specified network name is no longer available
Thus, my question:
Is there some setting in the windows SMB client or server that could cause something like this ?
It looks like an optimistic lock to me but windows doesn't do optimistic locks by default (it does opportunistic locks).
My first suspicion is that this problem is cause by the anti-virus software (Kaspersky) but the site admin swear that all AVs have an exclusion for this network path, both on client and on the file server.
The client OS is a mix of Windows XP, 7, 2003 and 2008R2 (via terminal services). It seems to happen only in time of heavy load (in the morning when everyone comes in or in he evening when everyone logs out).
Well, the answer was much simpler than I thought: a faulty device driver for the server's NIC apparently was the cause of all these trouble.
This really IS a programming problem IMHO but it may be reverted back to the way it 'worked' before by downgrading your OS. Windows 7 introduced a new locking mech into CIFS which is almost certainly the cause of your issue. This means you either need to update the program to work with the new lock scheme (programming prob) or you need to downgrade or find a compatibility fix (admin problems).
http://en.wikipedia.org/wiki/Server_Message_Block