Subject Re: [IBO] Multi-threaded ISAPI hangs
Author Helen Borrie
At 08:10 PM 4/06/2004 +0000, you wrote:
>D7, FB 1.5
>
>This is critical--I have this in production.
>
>I've written multithreaded apps a number of times, there's no rocket
>science about them-but I can not get this to work.
>
>I have a TIB_Session (first component on the DM, meaning it is the
>first one in the data module), and a TIB_Connection on a TDataModule.
>For each call into the ISAPI, I create a new instance of the data
>module. (Note that the connection doesn't have any thing
>that 'points' to the session, but I don't see where it should).
>
>Now when I run one connection at a time to the database, it works
>fine, but as soon as I try to run simultaneously, the DLL hangs. I
>have traced it (using CodeSite) to the 2nd instance trying to connect
>to the database.
>
>The server doesn't max out--there's no apparent reason for the hang.

The reason for the hang is very apparent.

> object iboConn: TIB_Connection
> PasswordStorage = psNotSecure
> Params.Strings = (
> 'PATH=<DB NAME>
> 'USER NAME=<USER NAME>')
> AfterDisconnect = iboConnAfterDisconnect
> Left = 152
> Top = 24
> SavedPassword = '...'
> end

You are using the Windows local connection. You can't multi-thread local
connections, period.

For an ISAPI connection you MUST have the following:

1. an explicit TIB_Session (as you do) but it must be the FIRST object in
the creation order
2. a tcp/ip connection through the local loopback server, i.e. the Server
is localhost, the Path is the absolute path to the database
3. nothing whatsoever that is interactive, e.g. a login dialog or any
modal dialog

On the subject of 3, if you are using the evaluation version, an ISAPI
module will never work, because it has a modal nag message. However, this
apparently is not part of your situation, or your single instance would not
have worked either.

But make sure that LoginPrompt is false and you don't have any ShowMessage
calls in your code.

Helen