Board index » delphi » Private directory and "Directory busy"

Private directory and "Directory busy"

I have written a server application that is listening to the Internet
for incoming connections. Everything is working well, but now I want to
direct the temporary files to my local HD. I am using a session
component and set the PrivateDir property to a folder dedicated for this
appliciation. When I do so, the first session is still functioning
properly, but when simultaneously a second session is initiated
(creating its own instance of a datamodule) I get the error message
"Directory busy".

Some further details:
* I have tried setting the PrivateDir and NetFileDir both in design and
in runtime (OnFormCreate).
* The application connects to an Oracle 8 database.
* On the main form a database component is used to allow opening a
logfile in the Oracle database for monitoring purposes. The default
session is used.
* The default setting of the Paradox lockfile is on the network, as
another application using a shared Paradox file is runing on all
woprkstations.
* When I ommit the lockfile settings the default settings on the network
are used (application + development dir resides on a network drive) and
no problems occur.

I think it must be something simple I am missing. Who helps me solving
the black spot....

Thanks, Herman Steigstra

 

Re:Private directory and "Directory busy"


Quote
> I have written a server application that is listening to the Internet
> for incoming connections. Everything is working well, but now I want to
> direct the temporary files to my local HD. I am using a session
> component and set the PrivateDir property to a folder dedicated for this
> appliciation. When I do so, the first session is still functioning
> properly, but when simultaneously a second session is initiated
> (creating its own instance of a datamodule) I get the error message
> "Directory busy".

Every Session has to have it's own PrivateDir (e.g two Sessions's ProvateDir
can't point to same directory);

Gert

Re:Private directory and "Directory busy"


OK, I can understand that, but why don't I have problems when I leave the
defaults what they are.....
Quote
Gert Kello wrote:
> Every Session has to have it's own PrivateDir (e.g two Sessions's ProvateDir
> can't point to same directory);

> Gert

Re:Private directory and "Directory busy"


Quote
> OK, I can understand that, but why don't I have problems when I leave the
> defaults what they are.....

I belive it's designed to work so: if the programmer sets PrivateDir, the
directory will be locked to force the programmer set the ProvateDir
exclusivly(and it is better if it IS set differently for each session). But
if it is not set by programmer the directory will not be locked to avoid
error messages when the second instance of app starts.

Gert

Re:Private directory and "Directory busy"


Each session must have its own private directory.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


But why don't I experience problems when I leave the default settings
untouched? (Only problem is messing up the network drive).
How do I handle hundreds of TCP/IP sessions (often simultaneous) each
having their own PrivateDir?

Herman Steigstra

Quote
"Bill Todd (TeamB)" wrote:
> Each session must have its own private directory.

> --
> Bill

> Bill Todd (TeamB)
> (TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


Quote
> But why don't I experience problems when I leave the default settings
> untouched? (Only problem is messing up the network drive).

You can get the "lock file grown too big" problem.

Quote
> How do I handle hundreds of TCP/IP sessions (often simultaneous) each
> having their own PrivateDir?

I would suggest:
1) Generate private dir under (AppPath)/Priv/XXXX
where XXXX is unique identifier for each session.
2)  The XXXX is generated with algorithm similar to

    repeat
        X := Format('%8x', [Random($FFFF)])
    until not DirectoryExists('AppPaths/Priv/'+X);

3) Every Session has to delete its dir after beeing closed (I belive You
can't delete it while Session is opened)
4) You have to to system clean-up time to time  - to delete directorys left
by Sessions that are closed but didn't delete it's private dir (like when
there was system crash or whatever)

I don't think it is the best way to handle this, and I would be glad if
anyone can suggest a better way;

Gert

Re:Private directory and "Directory busy"


If you are trying to handle hundreds of simultaneous connections you should,
IMHO, be using a database server, not Paradox tables.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


Of coarse, we are using an Oracle 8 server for storing the data, but I need the
sessions for the storage of the temporary tables created by the BDE......

I am still wondering how the BDE handles this when the default settings of
PrivateDir and NetFileDir are being used.

Herman Steigstra

Quote
"Bill Todd (TeamB)" wrote:
> If you are trying to handle hundreds of simultaneous connections you should,
> IMHO, be using a database server, not Paradox tables.

Re:Private directory and "Directory busy"


The BDE does not create local temporary tables when you are connected to a
database server unless you are using schema caching. Normally you should
leave the NetDir set to nothing and not change the PrivateDir. For an
explanation of how to use these settings with Paradox tables see TI247B at
www.borland.com/devsupport/bde/ti.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


On Sat, 20 Nov 1999 16:23:30 -0700, "Bill Todd \(TeamB\)"

Quote
<b...@dbginc.com> wrote:
>The BDE does not create local temporary tables when you are connected to a
>database server unless you are using schema caching.

...or cached updates?

Jan

Re:Private directory and "Directory busy"


Yes indeed.  BDE uses local temporary tables for a whole lot of things.

Quote
>Jan Sprengers wrote:

> On Sat, 20 Nov 1999 16:23:30 -0700, "Bill Todd \(TeamB\)"
> <b...@dbginc.com> wrote:

> >The BDE does not create local temporary tables when you are connected to a
> >database server unless you are using schema caching.

> ...or cached updates?

> Jan

------------------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)
Quote
> Got Paradox/Delphi database headaches?  ChimneySweep{tm} can help, FAST!
> http://www.sundialservices.com/cs3web.htm

Re:Private directory and "Directory busy"


You are right. I never use cached updates so I tend to forget them. Thanks.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


I am indeed using CachedUpdates in my C/S application. I would think that is
the way Inprise advises to handle updates to C/S databases.....
Anyway, I think I have found the solution after studying the help and the
source of the BDE units. At first I have tried to programmatically set the
PrivateDir to a value exactly equal to the default. Result: exception
"Directory busy", so it is not the location where you try to create the
private directory but the moment to do that. Now knowing that I have been
looking for the initialisation of the BDE. This is done by the dbiInit
procedure which is called automatically on the first call to any BDE function
like the opening of a table/query. This function is called with a nil
parameter for the evironment structure, resulting in filling in default values
for the PrivateDir: the directory where the application resides. Knowing that,
the only thing that should be done is calling this procedure before any BDE
function is called. For example, when the temporary files should reside in the
c:\windows\temp directory the following code will do:

uses ...... bde, BDEConst;
var Env: DBIenv;
begin
  FillChar(Env, SizeOf(Env), 0);
  StrPLCopy(Env.szLang, SIDAPILangID, SizeOf(Env.szLang) - 1);
  StrPLCopy(Env.szWorkDir, 'c:\windows\temp', SizeOf(Env.szWorkDir) - 1);
 Check(dbiInit(@Env));
......

I have put this code in the initialization part of the data module containig
all my BDE stuff and that will do the trick.
Bill, the reason why I want to overrule the defaults is that I want to prevent
my program to use the program directory (a network drive) for temporary
storage. When an application crashes the temporary files contaminate the
directory. Moreover some of the applications are distributed and will fail if
someone sets the access to the program folder to ReadOnly: temporary files
cannot be created then.

I think the proposed solution is so simple and essential that I would advise
everyone to include those lines in every C/S application. Bill, can you
comment on that?

Regards, Herman Steigstra

Quote
"Bill Todd (TeamB)" wrote:
> The BDE does not create local temporary tables when you are connected to a
> database server unless you are using schema caching. Normally you should
> leave the NetDir set to nothing and not change the PrivateDir. For an
> explanation of how to use these settings with Paradox tables see TI247B at
> www.borland.com/devsupport/bde/ti.

> --
> Bill

> Bill Todd (TeamB)
> (TeamB cannot respond to questions received via email)

Re:Private directory and "Directory busy"


You can simply assign the private directory path to Session.PrivateDir
before you open the database. Actually, Borland recommends using
TClientDataSet instead of cached updates for client/server applications.

--
Bill

Bill Todd (TeamB)
(TeamB cannot respond to questions received via email)

Go to page: [1] [2]

Other Threads