Subject RE: [IBO] Re: Problem with IB_Session in a TRemoteDataModule
Author Jason Wharton
Using TCP/IP is a must if you are doing multi-threading. The problems you
are seeing so far are due to this, as you suspect.

What you should do in your main/anchor data modules is have the TIB_Session
first in the modules creation order and then all subsequent components in
the module created will automatically align themselves to that session.
When creating your internal modules (that I presume won't have a session
component on them) be sure to have the host main/anchor data module as the
Owner so that they will align to its session and be sure to destroy them
when done. Don't pass these internal module instances from one main/anchor
module instance to another once they are instantiated.

Jason Wharton


> -----Original Message-----
> From: IBObjects@yahoogroups.com [mailto:IBObjects@yahoogroups.com]On
> Behalf Of rugbyjocker
> Sent: Thursday, November 03, 2005 5:24 AM
> To: IBObjects@yahoogroups.com
> Subject: [IBO] Re: Problem with IB_Session in a TRemoteDataModule
>
>
> Hey hey!
>
> I've continued what is now 2 days of searching to get an answer and I
> think I've found it... using a TIB_Connection instead and setting the
> protocol to TCP_IP from local seems to work. Something about
> firebird's client dll not being thread safe.
>
> Is this the way to go?
>
> Regards
> Sandy
>
>
> --- In IBObjects@yahoogroups.com, "rugbyjocker"
> <rugbyjock@b...> wrote:
> >
> > Hi,
> >
> > I'm trying to rig up a remote data module (multi-instance, apartment
> > threaded) that has a TIBODatabase component on it, and that
> creates a
> > series of child remote data modules all created as 'internal'. My
> > TIBOQueries and data providers all live on these child remote data
> > modules. This works fine until two clients try to talk to the server
> > at once. Then the server locks up completely.
> >
> > I've now made a new app with a single remote data module that is set
> > up as multi-instance and apartment threading, and on there I put a
> > TIBODatabase, a TIBOQuery and a data provider. Same problem. I've
> > tried adding a TIB_Session to the module, and assigning it to the
> > TIBODatase's and TIBOQuery's IB_Session property in the constructor.
> > It makes no difference. I feel like I'm fishing here.
> >
> > If I change the threading model of the remote data module
> to 'single'
> > then it works fine, so clearly the problem lies with the
> way multiple
> > threads are talking to IBObjects (seeing as there is NOTHING else on
> > the data module at all).
> >
> > I know I'm doing something daft here, but I can't see what it is.
> >
> > Any help would be greatly appreciated.
> > Regards
> > Sandy MacPherson
> >
> >
> >
> > For reference, here is the remote data module as it stands...
> >
> > unit TestRDM;
> >
> > {$WARN SYMBOL_PLATFORM OFF}
> >
> > interface
> >
> > uses
> > Windows, Messages, SysUtils, Classes, ComServ, ComObj, VCLCom,
> > DataBkr, DBClient, prjAppServer_TLB, StdVcl, Provider, DB,
> IBODataset,
> > IB_Components, IB_Session;
> >
> > type
> > TTestServer = class(TRemoteDataModule, ITestServer)
> > db: TIBODatabase;
> > qry: TIBOQuery;
> > prv: TDataSetProvider;
> > session: TIB_Session;
> > procedure RemoteDataModuleCreate(Sender: TObject);
> > private
> > { Private declarations }
> > protected
> > class procedure UpdateRegistry(Register: Boolean; const ClassID,
> > ProgID: string); override;
> > public
> > { Public declarations }
> > end;
> >
> > implementation
> >
> > {$R *.DFM}
> >
> > class procedure TTestesServer.UpdateRegistry(Register:
> Boolean; const
> > ClassID, ProgID: string);
> > begin
> > if Register then
> > begin
> > inherited UpdateRegistry(Register, ClassID, ProgID);
> > EnableSocketTransport(ClassID);
> > EnableWebTransport(ClassID);
> > end else
> > begin
> > DisableSocketTransport(ClassID);
> > DisableWebTransport(ClassID);
> > inherited UpdateRegistry(Register, ClassID, ProgID);
> > end;
> > end;
> >
> > procedure TTestesServer.RemoteDataModuleCreate(Sender: TObject);
> > begin
> > db.IB_Session := session;
> > qry.IB_Session := session;
> > end;
> >
> > initialization
> > TComponentFactory.Create(ComServer, TTestesServer,
> > Class_TestesServer, ciMultiInstance, tmSingle ???
> tmApartment??);
> > end.