Re: How to stop properly a TServerSocket running in a TThread

From: Legeard Luc <legeard_at_ganil.fr>
Date: Tue, 06 Feb 2007 10:54:23 +0100


Leandro Franco wrote:

> Hello...
>
> As far as I can tell I think you are deleting the socket (and some
> other things) before stopping the second thread and if you don't sync
> them that additional thread might try to access fields that had
> already been deleted. To solve it try to stop the thread before
> removing everything else in the StopServer... something like:
>
> void ServerRoot::StopGNetServer ()
> {
> // Stop the Network server
>
>
>
> if(fRunning==false) {
>
> cout<<"Server already stopped\n";
>
> return;
> }
>
>
>
> if(fThreadNet) {
> fRunning = false;
> TThread::Delete(fThreadNet);
> //delete fThreadNet;
> fThreadNet=NULL;
> cout<<"\n\t*********************\n\t Net Server
> stopped\n\t*********************\n";
> }else{
> cout <<" Thread no present\n";
> }
>
> :
> :
> :
>
>
> Cheers,
> Leo
>

Thanks for your answer but the result is always same! May be i forgot to say that sometime the stop works and sometime , it doesn't.

serv ->StopGNetServer();


         Net Server stopped
        *********************

root [20]
-- 
 ------------------------------------------------------------
 -  Luc LEGEARD                  - Tel   : 02 31 45 44 36   -
 -  GANIL  BP 55027 Bd Becquerel - Fax   : 02 31 45 47 97   -
 -  14076 CAEN Cedex 5           - mailto:legeard_at_ganil.fr  -
 -  Web http://www.ganil.fr
Received on Tue Feb 06 2007 - 10:54:52 CET

This archive was generated by hypermail 2.2.0 : Tue Feb 06 2007 - 17:50:01 CET