Page 1 of 1
DBMonitor & Dll issue - no log
Posted: Tue 19 Aug 2014 13:56
by Louarn
Hello all,
I have an issue with my dll and DB monitor since we upgrade our component to the 9.3.6 version.
Previously, we were in 8.3.11, and currently using delphi xe3.
Here is the pb: we have a application which call a DLL.
The application SQL is logged fine in DB Monitor, but not the SQL from de DLL.
In the dll, we have deactivated the SQL Monitor (removing the TOraSqlMonitor.create)
You will says: "hey dude, this is the fu*k !".
Well, in fact, yes and no.
When we have the "TOraSqlMonitor.create" in the dll, the loading of the dll hangs and never get back.
I am pretty sure that this is due to this line of code, in DBMonitorClient.pas:
Code: Select all
constructor TEventSendThread.Create(DBMonitor: TDBMonitor);
begin
inherited Create(True);
FConnectEvent := TEvent.Create(nil, True, False, '');
FEndEvent := TEvent.Create(nil, True, False, '');
{$IFDEF CLR}
Handle.IsBackGround := True;
{$ENDIF}
FDBMonitor := DBMonitor;
Resume;
if IsLibrary then
---> FConnectEvent.WaitFor(INFINITE);
end;
I do not have the source code of the version 8.3.11 (or previous) of this file, but this line of code seems to be here at least since te revision 8.6.12.
Has anyone have the history of this file, or encounter this kind of issue ?
Re: DBMonitor & Dll issue - no log
Posted: Wed 20 Aug 2014 12:00
by AlexP
Hello,
Try to reproduce the problem on the latest ODAC version 9.3.10. If the problem repeats, please send us a sample reproducing the problem to alexp*devart*com.
Re: DBMonitor & Dll issue - no log
Posted: Wed 20 Aug 2014 15:06
by Louarn
Hello Alex,
I have send you a mail with the source code.
In fact, very simple: just try to load a dll with a sql monitor in it.
This hangs.
App. code:
Code: Select all
unit Unit2;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
var
Form2 : TForm2;
DllHandle : THandle;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
try
DllHandle := LoadLibrary (Pchar(Edit1.Text));
except
ShowMessage(SysErrorMessage(GetLastError));
end;
end;
end.
Dll dpr code:
Code: Select all
library MyDll;
uses
System.SysUtils,
System.Classes,
orasqlmonitor;
{$R *.res}
var gorasqlmonitor : TOrasqlmonitor;
begin
//gorasqlmonitor := TOraSqlMonitor.create(nil);
end.
If you uncomment the TOraSqlMonitor.create(nil), the application will hang when loading the dll.
Hope this can help you finding the issue !
Re: DBMonitor & Dll issue - no log
Posted: Thu 21 Aug 2014 09:58
by AlexP
Thank you for the information. We have reproduced the problem and will investigate the reasons of such behavior.
Re: DBMonitor & Dll issue - no log
Posted: Thu 21 Aug 2014 15:19
by Louarn
Ok, nice to see that I am not alone with this pb.
Please keep me in touch if you find a solution !
Thanks.
Re: DBMonitor & Dll issue - no log
Posted: Tue 26 Aug 2014 08:04
by AlexP
We will inform you as soon as we have any results.
Re: DBMonitor & Dll issue - no log
Posted: Thu 18 Sep 2014 08:30
by Louarn
Hello,
Is there any news on this issue ?
I mean, if a correction has been identified or planned ?
Thanks !
Re: DBMonitor & Dll issue - no log
Posted: Thu 18 Sep 2014 12:29
by AlexP
We have investigated the problem more deeply and found out that, when dll is loading, the OS doesn't run other threads (and SQLMonitor uses threads), and we can't know whether the DLL was loaded or not.
Re: DBMonitor & Dll issue - no log
Posted: Thu 25 Sep 2014 12:48
by Louarn
Hello Alex,
Do you mean that this issue will not meet a solution ?
Re: DBMonitor & Dll issue - no log
Posted: Fri 26 Sep 2014 11:09
by AlexP
You should create ToraSQLMonitor in a separate method, and call this method after DLL is loaded.
Code: Select all
program MainProject;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
type
TCreateOraSQLMonitor = procedure;stdcall;
var
DllHandle: THandle;
CreateOraSQLMonitor: TCreateOraSQLMonitor;
begin
try
DllHandle := LoadLibrary (Pchar('DllProject.dll'));
CreateOraSQLMonitor := GetProcAddress(DllHandle, 'CreateOraSQLMonitor');
CreateOraSQLMonitor;
except
Writeln(SysErrorMessage(GetLastError));
end;
readln;
end.
Code: Select all
library DllProject;
uses
SysUtils,
Classes,
orasqlmonitor, DBMonitorClient, Ora;
{$R *.res}
var
gorasqlmonitor : TOrasqlmonitor;
procedure CreateOraSQLMonitor;
begin
gorasqlmonitor := TOrasqlmonitor.Create(nil);
end;
exports
CreateOraSQLMonitor;
begin
end.
Re: DBMonitor & Dll issue - no log
Posted: Fri 26 Sep 2014 11:55
by Louarn
Thanks AlexP, I will try and revert if it is Ko.
Don't be afraid, I will revert also if it is fine !
Re: DBMonitor & Dll issue - no log
Posted: Thu 09 Oct 2014 12:09
by Louarn
Hello AlexP,
Seems to be fine with this way of doing.
Calling in the application a method of the dll in order to start the Sql Monitor is ok !
Thanks.
Re: DBMonitor & Dll issue - no log
Posted: Thu 09 Oct 2014 13:54
by AlexP
Hello,
Glad to see that the issue was resolved. If you have any further questions, feel free to contact us.