Subject Embedded Fails on Program Restart,
Author inoffensive_2009
Hi Folks:

Developing on XP Home, VS2008 Pro, C++, Firebird 2.1.1.17910-0
SuperServer, ibpp-2-5-3-1.

I think this is more of a Firebird question than an IBPP question.

My application always uses embedded Firebird, as it's primary database or for configuration information if it's connecting to a multi-user database on a server.

If the user selects a multi-user database, the application disconnects from the the multi-user databse if it's using one, disconnects from the database used by the embedded firebird, starts up a new version of itself with CreateProcess(), and calls PostQuitMessage(0).

This, of course, leads to the possibility that a new instance of the application will start up before the old instance shuts down.

I'm getting the following error message:

SQL Message : -902
Unsuccessful execution caused by a system error that precludes
successful execution of subsequent statements

Engine Code : 335544344
Engine Message :
I/O error for file "<path and name of file used by embedded Firebird>"
Error while trying to open file
The process cannot access the file because it is being used by another process.

If I single step the first instance of the app to it's termination, with the debugger, and then attend to a messagebox I've added before attempting to open the database, for the second instance of the app, things work fine.

So it's a race condition.

But the first instance did close the database before the second instance started.

Should a second instance embedded Firebird be able to open a database that the first instance opened, if the first instance disconnected from it but not yet terminated?

Suggestions?

Thanks
Larry