Title: TRtcTimer cleanup problem Post by: Dany on October 10, 2017, 02:38:36 PM After the last update my server does not stop as nicely as before. I have a situation where i want to .Stop(..) a timer in the "ProviderModule" destructor. Since the destructor is run on application termination (and not on server stop) it will be executed *after* the background management thread has ended resulting in an AV.
To reproduce using the "RTCWebServer" Demo: 1. Open the rtcFileProvider.pas unit. 2. Add a private "TM: TRtcTimer;" and add a private "procedure DummyEventHandler;". 3. In DataModuleCreate, add these lines before "end": TM := TRtcTimer.Create(true); TRtcTimer.Enable(TM, 30 * 1000, DummyEventHandler); 4. In DataModuleDestroy, add "TRtcTimer.Stop(TM);" after "File_Provider := nil;". 5. Fix uses clause and give DummyEventHandler an empty implementation. Now if you start the server explicitly, access it, the stop it and after it has stopped close the application you'll get the same AV as me: in TRtcTimerThread.RemoveTrigger @"FCS.Acquire;". (Seems it can happen in other places too). I'm not sure this is the best way of doing things. I could probably move the creation, start and destruction to where i handle server start and stop and the problem will most likely go away. I'm posting this so that i can be clear about if this was unintended behaviour of if i was "lucky" when i first wrote that code. Regards, /Dany Title: Re: TRtcTimer cleanup problem Post by: D.Tkalcec (RTC) on October 10, 2017, 03:27:24 PM Thanks for reporting this. After a quick check, this looks like a bug in the TRtcTimer class implementation, which is trying to access Timer Threads even after they have already been destroyed (as a result of closing the Timer Pool). I'm working on fixing this now and will be releasing an update soon.
Best Regards, Danijel Tkalcec Title: Re: TRtcTimer cleanup problem Post by: D.Tkalcec (RTC) on October 10, 2017, 06:52:51 PM Please, download RTC SDK v8.33 (just released) and let me know if the problems are now resolved, or if you bump into any other issues.
Best Regards, Danijel Tkalcec Title: Re: TRtcTimer cleanup problem Post by: Dany on October 11, 2017, 07:16:37 AM Looks good! I'll shout if anything pops up. Thanks!
/D Title: Re: TRtcTimer cleanup problem Post by: D.Tkalcec (RTC) on October 11, 2017, 09:44:41 AM Ok. Thanks again for your feedback.
Best Regards, Danijel Tkalcec |