EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Need help on CBFS

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#5373
Posted: 03/12/2008 21:45:55
by Max Young (Basic support level)
Joined: 03/12/2008
Posts: 5

I have a question on how to properly use of the API.

Since I use the function like CbFsDeleteFile, CbFsCreateFile and it shows weird behaviour to me.

Can you guys explain me a little bit on how the CbFsGetFileInfo work? I'm trying to make a call to my functions from, for example, CbFsCreateFile and it jumps out to CbFsGetFileInfo, makes several iteration in there and then starts freezing at the end.

Do I use it in the wrong way?

Many thanks
Max
#5374
Posted: 03/13/2008 00:35:28
by Eugene Mayevski (EldoS Corp.)

Looks like you are causing a deadlock. What exactly are you doing in CbFsCreateFile?


Sincerely yours
Eugene Mayevski
#5378
Posted: 03/13/2008 00:58:47
by Max Young (Basic support level)
Joined: 03/12/2008
Posts: 5

Thnx for speedy reply :D

The thing I do inside CbFsCreateFile is make a call to another function which will invoke webservices to record a change I've done with CBFS onto the server. It might be that the operation take too much time.

So.. is it proper to embed that instruction inside CbFsCreateFile? Is there another way to accomplish what I want to do?

Best Regards
Max
#5379
Posted: 03/13/2008 01:35:19
by Volodymyr Zinin (EldoS Corp.)

Quote

It might be that the operation take too much time.

Try to set during development/debugging the MountMedia's Timeout parameter to 0 (it means - infinity). So the callbacks timeouts won't disturb.

Quote

The thing I do inside CbFsCreateFile is make a call to another function which will invoke webservices ...

Perhaps during this call the webservice performs some requests to the CallbackFS storage for which the CbFsCreateFile callback is processed. This is a cause of deadlock, because recursive calls from the CallbackFS callbacks are not possible.

Quote

So.. is it proper to embed that instruction inside CbFsCreateFile?

If it calls the CallbackFS recursively (implicitly or explicitly) that it isn't.

Quote

Is there another way to accomplish what I want to do?

Please specify exactly what the calls are you performing?
#5380
Posted: 03/13/2008 01:52:49
by Max Young (Basic support level)
Joined: 03/12/2008
Posts: 5

Code
private void CbFsCreateFile(CallbackFileSystem sender, string FileName, uint FileAttributes, ref IntPtr FileHandleContext)
        {
            sender.ResetTimeout(10000);
            GCHandle gch;
            FileName = mRootPath + FileName;
            FileHandleContext = IntPtr.Zero;
            if ((FileAttributes & (uint)CbFsFileAttributes.CBFS_FILE_ATTRIBUTE_DIRECTORY) != 0)
            {
                folder = true;
                DirectoryInfo dirInfo = Directory.CreateDirectory(FileName);
                gch = GCHandle.Alloc(dirInfo);
                FileHandleContext = (IntPtr)gch;
            }
            else
            {
                folder = false;
                FileInfo fInfo = new FileInfo(FileName);
                FileStream fs = fInfo.Create();
                fs.Close();
                gch = GCHandle.Alloc(fInfo);
                FileHandleContext = (IntPtr)gch;
            }
            CallService(folder, FileName);
        }


This is what I did to CbFsCreateFile.

Sometimes it works very well if I add only single file or folder. But also many times when I try to drag multiple files or folders to the virtual drive, it'd be deadlocked or does its operation for only one or two files before start freezing.
#5381
Posted: 03/13/2008 01:57:55
by Max Young (Basic support level)
Joined: 03/12/2008
Posts: 5

I'm trying 'not to touch' whatever inside the virtual drive or logical drive on both endpoints. All I do is just ask for either it is a folder or file and the FileName from CbFsCreateFile. This should not trouble the system, or it should?
#5382
Posted: 03/13/2008 02:02:43
by Eugene Mayevski (EldoS Corp.)

Quote
Max Young wrote:
All I do is just ask for either it is a folder or file and the FileName from CbFsCreateFile. This should not trouble the system, or it should?


What exactly are you asking? You seem to be trying to get information about the file, which is about to be opened, from CBFS? And this causes recursion and deadlock.

Since it's Callback File System, you (your application) are supposed to know, what file is to be opened, as you keep the data elsewhere. If it's the new file to be created, you have all flags necessary to perform the operation, passed to CbFsCreateFile. If it's an existing file, you have that file elsewhere and can check whether you can open this file or not.


Sincerely yours
Eugene Mayevski
#5383
Posted: 03/13/2008 02:04:23
by Volodymyr Zinin (EldoS Corp.)

Try to comment the call
Code
CallService(folder, FileName);
Will the problem still exist?
If it isn't then call it asynchronously (from another thread).
#5386
Posted: 03/13/2008 02:19:32
by Max Young (Basic support level)
Joined: 03/12/2008
Posts: 5

Vladie,

It works fine if I don't make a call to WS. No matter how complex the structure I drag into the virtual drive is and I really call it beautifulness of what you guys have done. :)

The reason I put my call inside CbFsCreateFile is I can see the nice way its iterate over folders/files structure that makes my life easier to record every single change to the structure. For example, order of iteration through folder/file fits very well with my business logic.

If it doesn't support my intention to record the change operation-by-operation, it would be painful for me :D
#5392
Posted: 03/13/2008 03:19:44
by Volodymyr Zinin (EldoS Corp.)

1. Try to call the service asynchronously.
2. If buffered i/o operations are used in the callbacks you must set the CallbackFileSystem.UseSystemCache property to TRUE.
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 6900 times

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




|

Back to top

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

Got it!