EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Mapper sample ignore DesiredAcces in file open callback

Posted: 07/31/2015 07:38:34
by William Levra-Juillet (Priority Standard support level)
Joined: 09/05/2013
Posts: 49

One of our customer reported a problem:
- Open a file for GENERIC_READ
- Do some read fom that file
- Close that file
- Reopen it straight away with GENERIC_WRITE + GENERIC_READ
- Try to write to it
-> FAIL (Apparently, it fails because the file is not closed/reopen, the same file is reused)

I tried with the mapper sample, and the problem doesn't occur because the file is always open for "READ + WRITE" (and DesiredAccess is ignored).
If I change mapper sample to use DesiredAccess the problem happens.

So, my question is why do you always use READ+WRITE when opening a file in mapper sample?
Nothing specific mentionned here:

I'd like to understand the reasons and the consequences if we decide to do the same in our production code.

Posted: 07/31/2015 08:16:34
by Eugene Mayevski (Team)

1) Mapper sample should be kept simple
2) The sample was written at the time when CallAllOpenCloseCallbacks property didn't exist and the callback was called only once for all concurrent open operations. So to avoid opening the backend file in read-only mode when the second open operation wants to open the file for writing, the file is opened in read+write mode.

How to open the file in your application depends on how you set CallAllOpenCloseCallbacks property and on the way your backend operates. For example, in our SFTP Net Drive application we always open remote files for read+write because some SFTP servers don't let you open the file twice and we reuse the opened handle for multiple operations.

If you want to discuss and investigate your particular problem, please let me know.

Sincerely yours
Eugene Mayevski



Topic viewed 2573 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!