Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread thread safe - ewb web module + edb tables
Sat, Dec 30 2017 8:56 AMPermanent Link

kamran

Hi

So I have a  module which is called multiple times within an ewb application that generates data for use in ticket printing.

My issue is that it appears to lock the edb server. (As the module stops generating data after working for a bit until the server is reset again)

So it transpires that I need the web module to be thread safe and the edb engine cannot be placed on a web module as it is called every time the webmodule is used.

1. Any guidance on and / or a simple generic template I could use would be extremely helpful ?

I have looked at the "ewb databasemodule" example and the "unique sessions" section in the edb manual but is is not easy for me to translate.

2. Not sure how could do I debug the web module. to see what is happening;

Again some pointers would be helpful.


best regards


Kamran
Wed, Jan 3 2018 4:32 AMPermanent Link

Uli Becker

> My issue is that it appears to lock the edb server. (As the module stops generating data after working for a bit until the server is reset again)

1. Are you trapping all possible exceptions (silently)?
2. Are you using any message boxes?

I once ran into problems when I forgot to take out a message box within
an exception. That blocked everything.

Uli
Wed, Jan 3 2018 5:17 PMPermanent Link

kamran

Hi Uli

Happy New Year.

Yes I will check my code for that.!

Thanks

Kamran

Uli Becker wrote:

> My issue is that it appears to lock the edb server. (As the module stops generating data after working for a bit until the server is reset again)

1. Are you trapping all possible exceptions (silently)?
2. Are you using any message boxes?

I once ran into problems when I forgot to take out a message box within
an exception. That blocked everything.

Uli
Fri, Jan 5 2018 10:37 AMPermanent Link

Matthew Jones

kamran wrote:

> Yes I will check my code for that.!

If this is consistent, then consider adding madExcept to it. I had a similar issue, and you can create a thread that checks for the presence of a file. If it finds it, rename the file (prevent double trigger) and then generate an exception and catch it. madExcept will then take a grab of all thread stacks and dump it to disk. You can then see exactly what each thread is doing.



unit uGrabActiveThreads;

interface

procedure GrabActiveThreadsCheck;


implementation

uses syncobjs, classes, sysutils, uServerOptions, madExcept, Windows;

var
   g_xSyncControl : TCriticalSection;


type
   EAdminRequest = class(Exception);

procedure GrabActiveThreadsCheck;
var
   szFile : String;
   szNewFile : String;
begin
   if not assigned(g_xSyncControl) then
      exit;

   g_xSyncControl.Enter;
   try
      szFile := g_xLatestConfig.DataRootPath + '\data\stackdump.txt';
      if FileExists(szFile) then
      begin
         szNewFile := g_xLatestConfig.DataRootPath + '\data\__stackdump.txt';
         DeleteFile(PChar(szNewFile));
         RenameFile(szFile, szNewFile);

         try
            raise EAdminRequest.Create('Stack dump requested by admin');
         except
            on errInfo : Exception do
               HandleException(etNormal, errInfo);
         end;
      end;
   finally
      g_xSyncControl.Leave;
   end;
end;

initialization
   g_xSyncControl := TCriticalSection.Create;

finalization
   FreeAndNil(g_xSyncControl);


end.
Sun, Jan 7 2018 11:15 AMPermanent Link

kamran

Hi Matthew

That's great.. I will check it out !

Thanks

Kamran


"Matthew Jones" wrote:

kamran wrote:

> Yes I will check my code for that.!

If this is consistent, then consider adding madExcept to it. I had a similar issue, and you can create a thread that checks for the presence of a file. If it finds it, rename the file (prevent double trigger) and then generate an exception and catch it. madExcept will then take a grab of all thread stacks and dump it to disk. You can then see exactly what each thread is doing.



unit uGrabActiveThreads;

interface

procedure GrabActiveThreadsCheck;


implementation

uses syncobjs, classes, sysutils, uServerOptions, madExcept, Windows;

var
   g_xSyncControl : TCriticalSection;


type
   EAdminRequest = class(Exception);

procedure GrabActiveThreadsCheck;
var
   szFile : String;
   szNewFile : String;
begin
   if not assigned(g_xSyncControl) then
      exit;

   g_xSyncControl.Enter;
   try
      szFile := g_xLatestConfig.DataRootPath + '\data\stackdump.txt';
      if FileExists(szFile) then
      begin
         szNewFile := g_xLatestConfig.DataRootPath + '\data\__stackdump.txt';
         DeleteFile(PChar(szNewFile));
         RenameFile(szFile, szNewFile);

         try
            raise EAdminRequest.Create('Stack dump requested by admin');
         except
            on errInfo : Exception do
               HandleException(etNormal, errInfo);
         end;
      end;
   finally
      g_xSyncControl.Leave;
   end;
end;

initialization
   g_xSyncControl := TCriticalSection.Create;

finalization
   FreeAndNil(g_xSyncControl);


end.
Image