EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Multiple threads and Enumerate Directory callback

Posted: 09/29/2008 15:25:22
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

I have an issue that I was wondering if other users had, or if Eugene or Vladimir could explain it and help me with it.

The issue is this, when I am looking at my virtual drive in Windows Explorer there are two panes to the explorer window. The left pane expands the drive and shows all of its subfolders, while the right pane opens the drive and shows subfolders and files in the root.

Because of this I get calls to Enumerate Directory from two different threads in the Windows Explorer program. Is there some way of telling CbFs that these are two different threads and therefore the displays of the subfolders and files should be handled differently?

The evidence I am seeing makes me think that there is some confusion, either in the OS itself, or in CbFs, as to which directory enumeration it is showing on the screen. I get cases where I see two subfolders of the same name or sometimes I do not see a subfolder that I know is there. Refreshing the view sometimes helps and sometimes doesn't.

Is this another case where I need to be calling your NotifyDirectoryChange function? That doesn't really make sense to me, since I am not changing the directory in this case, just viewing it.

Anyway, any help from anyone in this area would be greatly appreciated.
Posted: 09/30/2008 10:36:55
by Volodymyr Zinin (Team)


It's possible to identify different enumerations using the EnumerationContext parameter of the EnumerateDirectory callback. It's normal when at the same time there are two or more enumerations for some folder. And in this case it's necessary to give the same file list for all enumerations for the same folder.
Perhaps the problem is because your EnumerateDirectory for some enumeration report some file/subdirectory twice.

The NotifyDirectoryChange function should only be used when some files/directories are added/deleted/modified in some nonstandard way - not by adding/deleting/modifying them via the virtual disk. For example if you decide that some file mustn't be shown in a directory then you call this function and won't specify the file in the following enumerations.
Posted: 09/30/2008 15:41:05
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Yes, when I started investigating and using the EnumerationContext for saving my database information that I use to enumerate the directories that seemed to solve my problem, so the EnumerationContext in CbFs is thread specific and therefore really does separate between the two enumerations.
Posted: 10/02/2008 03:12:31
by Volodymyr Zinin (Team)

Sid Schipper wrote:
so the EnumerationContext in CbFs is thread specific

It's not thread-specific but enumeration-specific. For example someone (or something) can call win32 api FindFirst for some directory on a CallbackFS virtual disk from the one thread and than call FindNext from another thread.
Posted: 10/02/2008 13:31:13
by Sid Schipper (Standard support level)
Joined: 03/14/2008
Posts: 285

Yes, I understand it now and things are working just fine. Thank you for your help.



Topic viewed 3613 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!