Word and Excel need byte range locking, don't they

Richard Sharpe rsharpe at richardsharpe.com
Thu May 27 17:12:41 GMT 2004


Hi,

This would be funny if it weren't so sad.

When word opens a file there is an enormous amount of activity. It opens
the file, reads it, closes it, opens it again, and so on. At some point it
takes out byte-range locks way beyond the end of the file (OLE?) and
unlocks a different range of bytes also beyond the end of the file.

So, you need byte range locks, or do you? (Don't ask why this question
arose, just read between the lines.)

It turns out that there are two different ways to avoid the need for byte
range locks (ie, you can return STATUS_NOT_IMPLEMENTED and get away with
it) at least for Word and Excel.

At some point during the dance that word does with the file server, it
opens the same file a second time and asks for an OpLock on the file
again. As long as Word gets the OpLock on the first file, and it is broken
on the second open, refusing the byte-range lock does not matter.

Even more interesting, returning STATUS_SHARING_VIOLATION on the second
open also allows Word to work without the need for byte-range locks.

Sigh. Life's like that.

Regards
-----
Richard Sharpe, rsharpe[at]richardsharpe.com, rsharpe[at]samba.org,
sharpe[at]ethereal.com, http://www.richardsharpe.com


More information about the samba-technical mailing list