Newsgroups : Borland : borland.public.delphi.internet.winsock : 2006 May : Re: CookieManager thread safety

www.cryer.info
Managed Newsgroup Archive

Re: CookieManager thread safety

Subject:Re: CookieManager thread safety
Posted by:"dk_sz" (dk_..@hotmail.com)
Date:Tue, 9 May 2006 02:44:05

> Why are you freeing the CookieManager at all while your TIdHTTP instances
> are still using it?

I am not. I am freeing cookie manager when
all http connections are all done and freed.

But, and this is my theory based on what I experience,
because of the thread/notification code, the TidHTTPs
are not taken off the notification list correctly...

I suspect this may happen if multiple are trying at the same time.
(perhaps a search, insert, etc. overlap goes wrong midway?)

AV happens when I free the cookie manager
(after all TidHttp have been freed), specificly in:
"
  if FFreeNotifies <> nil then
  begin
    while Assigned(FFreeNotifies) and (FFreeNotifies.Count > 0) do
      TComponent(FFreeNotifies[FFreeNotifies.Count - 1]).Notification(Self,
opRemove);
    FreeAndNil(FFreeNotifies);
  end;
"

This list SHOULD be empty... But isn't always... And thus AVs.

I imagine reason is then TidHttp is freed, this calls
(in TComponent) RemoveFreeNotification >> TList.Remove...
- search (for removing item) an item returns index
- thread switch with addition/insert/deletion of an item,
- thread switch back and the, now wrong, index is used for delete


best regards
Thomas

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive