RTC Forums
November 24, 2024, 12:56:38 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Application hang when use DLL with Rtc Components  (Read 7089 times)
ISIGest
RTC Expired
*
Posts: 121


« on: October 27, 2016, 10:03:24 AM »

Hi, I've a big problem with an Application that use a DLL that contain a simple TRtcHttpClient and an TRtcClientModule used to call a function to remote server.
The Dll work fine but my application hang (for about 30s) when close.
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #1 on: October 27, 2016, 10:43:42 AM »

I found some info into log:

2016-10-27 11:41:51.667; rtcWInetHttpCliProv Finalizing ...
2016-10-27 11:41:51.670; CloseThreadPool begin ...
2016-10-27 11:41:51.672; Threads Runnning: 2
2016-10-27 11:41:51.674; Post ThreadQuit 13716
2016-10-27 11:41:51.687; Post ThreadQuit 18776
2016-10-27 11:41:51.699; Waiting for all Threads to close ...
2016-10-27 11:42:22.905; Done waiting, 2 Threads (2+0) still busy!

BUSY???
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #2 on: October 27, 2016, 10:49:50 AM »

If I try to CloseThreadPool manually I've this result into log:

Code:
2016-10-27 11:48:33.933; rtcWInetHttpCliProv Finalizing ...
2016-10-27 11:48:33.936; rtcWInetHttpCliProv Finalized.
2016-10-27 11:48:33.938; rtcWinHttpCliProv Finalizing ...
2016-10-27 11:48:33.940; rtcWinHttpCliProv Finalized.
2016-10-27 11:48:33.942; rtcSocketCliProv Finalizing ...
2016-10-27 11:48:33.944; rtcSocketCliProv Finalized.
2016-10-27 11:48:33.946; rtcSockBaseSyn Finalizing ...
2016-10-27 11:48:33.948; rtcSockBaseSyn Finalized.
2016-10-27 11:48:33.950; rtcWinSocket Finalizing ...
2016-10-27 11:48:33.953; rtcWinSocket Finalized.
2016-10-27 11:48:33.955; rtcWinSock Finalizing ...
2016-10-27 11:48:33.957; rtcWinSock Finalized.
2016-10-27 11:48:33.959; rtcSockBase Finalizing ...
2016-10-27 11:48:33.961; rtcSockBase Finalized.
2016-10-27 11:48:33.963; rtcHWndPool Finalizing ...
2016-10-27 11:48:33.965; rtcHWndPool Finalized.
2016-10-27 11:48:33.967; rtcSocketPool Finalizing ...
2016-10-27 11:48:33.969; rtcSocketPool Finalized.
2016-10-27 11:48:44.300; rtcFunction Finalizing ...
2016-10-27 11:48:44.303; rtcFunction Finalized.
2016-10-27 11:48:54.669; rtcTimer Finalizing ...
2016-10-27 11:49:05.076; rtcTimer Finalized.
2016-10-27 11:49:05.079; rtcThrPool Finalizing ...
2016-10-27 11:49:05.081; Checking Virtual Threads ...
2016-10-27 11:49:05.083; All Virtual Threads released.
2016-10-27 11:49:05.085; Releasing Thread Pool
2016-10-27 11:49:05.088; Thread Pool released.
2016-10-27 11:49:05.090; Releasing Thread List
2016-10-27 11:49:05.092; Thread List released
2016-10-27 11:49:05.094; rtcThrPool Finalized.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: October 27, 2016, 11:41:08 AM »

How are TRtcHttpClient and TRtcClientModule components configured (properties)? I guess TRtcHttpClient component has MultiThreaded=TRUE, but how are the other properties set up on the TRtcHttpClient component (which define the API to be used) and does the TRtcClientModule have AutoSyncEvents=TRUE or FALSE? Are you closing the connection on all TRtcHttpClient components (using "DisconnectNow") before destroying Forms and/or DataModules used by the components?

Best Regards,
Danijel Tkalcec
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 on: October 27, 2016, 01:59:25 PM »

I've released the next RTC SDK update (v7.58). Using this update, if you manually call the "rtcShutDown" procedure before closing your Application, there should be no delays during your Application's finalization (at least none caused by RTC), but please note that using "rtcShutDown" will result in Memory Leaks and most likely cause Access Violations during shut-down.

A much better and cleaner approach would be to make sure that all RTC connections are closed (using DisconnectNow on the Client and StopListeNow on the Server) before destroying RTC components and any Forms and/or DataModules used by RTC components. If you are using the TRtcQuickJob component or directly posting jobs to the RTC Thread Pool by using the PostQuickJob procedure, you should also make sure that all jobs are finished before closing the Application (TRtcQuickJob component has properties to check the number of jobs left).

Judging by the LOG entries you've posted above, something is preventing two RTC Worker Threads and at last one RTC Timer Thread from terminating, which means that two events triggered by RTC components are running in the background and either (A) waiting for something or (B) trying to access the Main Thread - while your Application is shutting down.

If you are closing all RTC connections before terminating your Application (DisconnectNow / StopListenNow) and do NOT use any other RTC classes or components which might be using RTC Threads or Timers, then I will need more information about the way you are using RTC components. A list of properties on all RTC components would be a good start. Example Projects demonstrating the issue would be even better, so I can debug this locally to find out what is going on.

Best Regards,
Danijel Tkalcec
Logged
ISIGest
RTC Expired
*
Posts: 121


« Reply #5 on: October 28, 2016, 09:05:49 AM »

I've solved by unload the DLL before on each use.

Load -> Call -> Unload

and skip the Detach on Application Close.

Regards
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #6 on: October 28, 2016, 09:49:41 AM »

I would have preffered to find the reason for RTC Worker and Timer Threads not terminating, but ... if you can not provide additional information and you are happy with your solution, I'm not going to argue.

Best Regards,
Danijel Tkalcec
Logged
HelgeLange
RTC Expired
*
Posts: 100


« Reply #7 on: October 28, 2016, 09:36:29 PM »

I use a lot of DLLs and BPLs that are loaded dynamically and some of them use RTC, I have some problems to shut down sometimes. Not using worker threads there. Can't say, where it hangs, it's a small pìece of code some thing like WaitKillThread something, looks like windows internals, not my code for sure.

What could I use to know, if it's the fault of RTC ? I use RTC als runtime BPL.

Helge
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #8 on: October 29, 2016, 09:39:45 AM »

You can start by downloading the latest RTC SDK version and rebuilding any DLLs, EXEs and BPLs where you are using RTC components with a RTC_DEBUG compiler define declared. You can either delcare the RTC_DEBUG define in every Project or in the rtcDeploy.inc file (located in the RTC Lib folder).

If an Application "hangs" when closing and this "hanging" is caused by RTC SDK or by your code executed from inside RTC events, it will be visible in RTC log files (see LOG entries from ISIGest above for an example).

Best Regards,
Danijel Tkalcec
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.028 seconds with 17 queries.