EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Handling "Open File Handles Limit"

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#13878
Posted: 07/09/2010 11:10:31
by Mridul Pentapalli (Standard support level)
Joined: 11/30/2009
Posts: 26

Hi,

We are using CBFS to provide disk access to an embedded device. The device has a hard limit on the number of open file handles. I occasionally cross the limit when trying to copy a large no. of files to the device.

Is it possible to tell CBFS to limit the no. of open file handles? If not, can you please provide a sample code that uses ReleaseUnusedFiles. The help file is not very clear about the usage, and provides contradictory information about whether ReleaseUnusedFiles can be used from a callback or not.

Regards,
Mridul.
#13879
Posted: 07/09/2010 12:01:17
by Eugene Mayevski (EldoS Corp.)

Do I understand you right that in some cases the remote device fails to open more files? In this case you can just return error from OnFileOpen callback.

Regarding ReleaseUnusedFiles - documentation is quite clear on this. You can call this method to tell the system close files which are not used anymore, but which are opened for some reason. Do NOT call ReleaseUnusedFiles in event handler. I.e. you can call this method on timer (say once per 10 seconds) from some worker thread or from main thread of the application.

Regarding guard objects - the call (in C#) would look like:

Code

Monitor MyMonitor = new Monitor();

void HandleFileOpen(...) // handles OnFileOpen event
{
  MyMonitor.Enter();
  try
  {
   // your business logic here
  }
  finally {
    MyMonitor.Leave();
  }
}

void OnTimer(...)
{
  MyMonitor.Enter();
  try
  {
     CBFS.ReleaseUnusedFiles();
  }
  finally {
    MyMonitor.Leave();
  }
}


Sincerely yours
Eugene Mayevski

Reply

Statistics

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