Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: destroy Threadclass and ondisconnect event
| Subject: | Re: destroy Threadclass and ondisconnect event |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Wed, 13 Feb 2008 10:31:46 |
"emre varol" <none@none.com> wrote in message
news:47b306b9$1@newsgroups.borland.com...
> Ok I will control my code again but I couldnt understand exacly below..
> "Your queuing code already does that, but you are not protecting your room
> array itself."
> Q1- why?
Because you have multiple threads accessing your 'rooms' variable at
potentially the same time without locking access to it. The
Troom.kritiklist member has a lock, but the 'rooms' array itself does not.
> rooms[ 1 ].kritiklist.locklist ---> for example alot of threads can access
> this line in the same time.But I think this does not cause any problem? is
> it true?
That depends on whether or not you ever add/remove any of the rooms to/from
the array.
> Only one variable( name:string ) is not being protect because it does
> not change any where.
It still needs to be protected. Strings are reference counting. You may
not be changing the character value, but the reference count is modified
internally when you assign the String to other variables.
> When I check log file for example I see 70 lines 'interesting' expression
> for 10 seconds.What about this?
If the OnConnect event was triggered successfully, then the OnDisconnect
event is GUARANTEED to be triggered. The TIdPeerThread thread calls
OnDisconnect in a try..finally block internally. It does not matter if an
exception is raised inside the OnExecute event or not, the 'finally' block
will ensure that OnDisconnect is triggered regardless. The only way that
could not be the case is if the OnConnect event handler raises its own
exception.
> when the user try to connect the server and if the connection is not
> ensured
> than onthisconnect event is not called and TMypeerthread will free.is it
> true?
If the client is not fully connected to the server, then the OnConnect and
OnDisconnect events will not be triggered, as there is no connection for
your code to interact with.
> Or TMypeerthread class is created only if connection is established
It is created only if the server was successful in accepting the client's
inital connection. Whether or not the server decides to keep the connection
after accepting it is dictated by the server's MaxConnections property,
though.
Gambit
none