Does it work there? Doesn't it give the exception? Regards,
SZ ----- Original Message ----- From: "Arno Garrels" <[EMAIL PROTECTED]> To: "ICS support mailing" <twsocket@elists.org> Sent: Friday, June 09, 2006 11:03 AM Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem > Below a simple test program, if you don't have ICS-SSL exchange > TSslHttpCli by THttpCli. Does it work for you? > > unit Unit1; > > interface > > uses > Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, > Forms, > Dialogs, OverbyteIcsWndControl, OverbyteIcsHttpProt, StdCtrls; > > type > TMyThread = class(TThread) > public > procedure Execute; override; > end; > TForm1 = class(TForm) > SslHttpCli1: TSslHttpCli; > SslHttpCli2: TSslHttpCli; > btnAttachTothread: TButton; > btnAttachtoMainThread: TButton; > procedure btnAttachTothreadClick(Sender: TObject); > procedure FormCreate(Sender: TObject); > procedure FormDestroy(Sender: TObject); > procedure btnAttachtoMainThreadClick(Sender: TObject); > private > FThread : TMyThread; > public > { Public declarations } > protected > procedure WmAttachMain(var Msg: TMessage); message WM_USER + 3; > end; > > var > Form1: TForm1; > > implementation > > {$R *.dfm} > > { TMyThread } > > procedure TMyThread.Execute; > var > Msg: tagMsg; > begin > while GetMessage(Msg, 0, 0, 0) do > begin > if Msg.message = WM_USER + 1 then > TSslHttpCli(Msg.WParam).ThreadAttach > else if Msg.message = WM_USER + 2 then > begin > TSslHttpCli(Msg.WParam).ThreadDetach; > Postmessage(Form1.Handle, WM_USER + 3, Msg.WParam, 0); > end > else begin > TranslateMessage(Msg); > DispatchMessage(Msg); > end; > end; > Terminate; > end; > > procedure TForm1.FormCreate(Sender: TObject); > begin > FThread := TMyThread.Create(False); > end; > > procedure TForm1.FormDestroy(Sender: TObject); > begin > PostThreadMessage(FThread.ThreadID, WM_QUIT, 0, 0); > end; > > procedure TForm1.WmAttachMain(var Msg: TMessage); > begin > TSslHttpCli(Msg.WParam).ThreadAttach; > end; > > procedure TForm1.btnAttachtoMainThreadClick(Sender: TObject); > begin > PostThreadMessage(FThread.ThreadID, WM_USER + 2, Integer(SslHttpCli1), > 0); > PostThreadMessage(FThread.ThreadID, WM_USER + 2, Integer(SslHttpCli2), > 0); > end; > > procedure TForm1.btnAttachTothreadClick(Sender: TObject); > begin > SslHttpCli1.ThreadDetach; > PostThreadMessage(FThread.ThreadID, WM_USER + 1, Integer(SslHttpCli1), > 0); > SslHttpCli2.ThreadDetach; > PostThreadMessage(FThread.ThreadID, WM_USER + 1, Integer(SslHttpCli2), > 0); > end; > > end. > > // DFM // > > object Form1: TForm1 > Left = 0 > Top = 0 > Caption = 'Form1' > ClientHeight = 293 > ClientWidth = 426 > Color = clBtnFace > Font.Charset = DEFAULT_CHARSET > Font.Color = clWindowText > Font.Height = -11 > Font.Name = 'Tahoma' > Font.Style = [] > OldCreateOrder = False > OnCreate = FormCreate > OnDestroy = FormDestroy > PixelsPerInch = 96 > TextHeight = 13 > object btnAttachTothread: TButton > Left = 38 > Top = 88 > Width = 127 > Height = 25 > Caption = 'AttachTothread' > TabOrder = 0 > OnClick = btnAttachTothreadClick > end > object btnAttachtoMainThread: TButton > Left = 38 > Top = 119 > Width = 127 > Height = 25 > Caption = 'AttachtoMainThread' > TabOrder = 1 > OnClick = btnAttachtoMainThreadClick > end > object SslHttpCli1: TSslHttpCli > LocalAddr = '0.0.0.0' > ProxyPort = '80' > Agent = 'Mozilla/4.0 (compatible; ICS)' > Accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*' > NoCache = False > ContentTypePost = 'application/x-www-form-urlencoded' > MultiThreaded = False > RequestVer = '1.0' > FollowRelocation = True > LocationChangeMaxCount = 5 > BandwidthLimit = 10000 > BandwidthSampling = 1000 > Options = [] > SocksAuthentication = socksNoAuthentication > Left = 32 > Top = 36 > end > object SslHttpCli2: TSslHttpCli > LocalAddr = '0.0.0.0' > ProxyPort = '80' > Agent = 'Mozilla/4.0 (compatible; ICS)' > Accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*' > NoCache = False > ContentTypePost = 'application/x-www-form-urlencoded' > MultiThreaded = False > RequestVer = '1.0' > FollowRelocation = True > LocationChangeMaxCount = 5 > BandwidthLimit = 10000 > BandwidthSampling = 1000 > Options = [] > SocksAuthentication = socksNoAuthentication > Left = 64 > Top = 36 > end > end > > > Fastream Technologies wrote: >> Hello, >> >> ----- Original Message ----- >> From: "Arno Garrels" <[EMAIL PROTECTED]> >> To: "ICS support mailing" <twsocket@elists.org> >> Sent: Thursday, June 08, 2006 7:48 PM >> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >> >> >>> Fastream Technologies wrote: >>>> Arno, >>>> >>>> In the last code you sent, this problem STILL exists! >>> >>> I'm afraid, the fix below is in the code since Monday. >> >> Perhaps we need another -more comprehensive- fix. Francois, AFAIK you >> were able to reproduce the problem, right? Could you check with the >> latest code. Something must have gone bad because when I said it was >> fixed, it was fixed. >> >>> >>>> The other >>>> problem was because of wrong package lib included in the project. >>> >>> What "other problem" do you mean (sounds very mysterious to me)? >> >> I mean the half downloads problem. That was because two ics packages >> were linked. :o( Sorry for bothering you guys. Your suggestion that >> the package was not good worked for me to find out... >> >> Best Regards, >> >> SZ >> >>> >>>> Sorry for that. >>>> >>>> Best Regards, >>>> >>>> SZ >>>> >>>> ----- Original Message ----- >>>> From: "Francois PIETTE" <[EMAIL PROTECTED]> >>>> To: "ICS support mailing" <twsocket@elists.org> >>>> Sent: Monday, June 05, 2006 2:35 PM >>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>> >>>> >>>>> Still one problem. Arno fixed it (He sent a private message to me). >>>>> Move the line >>>>> FWndHandler := nil; // THIS ONE ADDED >>>>> from ThreadDetach to DeallocateHWnd so that the later looks like: >>>>> procedure TIcsWndControl.DeallocateHWnd; >>>>> begin >>>>> if FHandle = 0 then >>>>> Exit; // Already done >>>>> >>>>> GWndHandlerPool.Lock; >>>>> try >>>>> FreeMsgHandlers; >>>>> if Assigned(FWndHandler) and (FWndHandler.FMsgCnt <= 0) then >>>>> GWndHandlerPool.FreeWndHandler(FWndHandler); >>>>> FHandle := 0; >>>>> FWndHandler := nil; // THIS ONE ADDED >>>>> finally >>>>> GWndHandlerPool.UnLock; >>>>> end; >>>>> end; >>>>> >>>>> Thank to Arno. >>>>> >>>>> -- >>>>> Contribute to the SSL Effort. Visit >>>>> http://www.overbyte.be/eng/ssl.html -- >>>>> [EMAIL PROTECTED] >>>>> http://www.overbyte.be >>>>> >>>>> >>>>> >>>>> ----- Original Message ----- >>>>> From: "Francois PIETTE" <[EMAIL PROTECTED]> >>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>> Sent: Monday, June 05, 2006 1:11 PM >>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>> >>>>> >>>>>> Problem fixed ! >>>>>> >>>>>> In OverbyteIcsHttpProt.pas, add: >>>>>> >>>>>> {$IFDEF COMPILER2_UP} >>>>>> procedure THttpCli.ThreadAttach; >>>>>> begin >>>>>> inherited ThreadAttach; >>>>>> FCtrlSocket.ThreadAttach; >>>>>> end; >>>>>> >>>>>> procedure THttpCli.ThreadDetach; >>>>>> begin >>>>>> inherited ThreadDetach; >>>>>> FCtrlSocket.ThreadDetach; >>>>>> end; >>>>>> {$ENDIF} >>>>>> >>>>>> Don't forget to add the declarations in the public section. >>>>>> >>>>>> In OverbyteIcsWndControl, add a line in ThreadDetach so that it >>>>>> looks like: >>>>>> procedure TIcsWndControl.ThreadDetach; >>>>>> begin >>>>>> if GetCurrentThreadID <> FThreadID then >>>>>> raise EIcsException.Create('Cannot detach from another >>>>>> thread'); Self.DeallocateHWnd; >>>>>> FWndHandler := nil; // THIS ONE ADDED >>>>>> end; >>>>>> >>>>>> >>>>>> In OverbyteIcsWSocket.pas, delete the declaration of >>>>>> TCustomWSocket.FThreadID. >>>>>> >>>>>> That's it. >>>>>> Should work. At least it work in my small test prog: >>>>>> Create a form, drop a TButton, a TMemo and a THttpCli. Add the >>>>>> following code: >>>>>> >>>>>> unit OverbyteIcsSimpleThread1; >>>>>> >>>>>> interface >>>>>> >>>>>> uses >>>>>> Windows, Messages, SysUtils, Variants, Classes, Graphics, >>>>>> Controls, Forms, >>>>>> Dialogs, StdCtrls, OverbyteIcsWndControl, OverbyteIcsWSocket, >>>>>> OverbyteIcsHttpProt; >>>>>> >>>>>> type >>>>>> TWorkerThread = class(TThread) >>>>>> public >>>>>> FHttpCli : THttpCli; >>>>>> procedure HttpCliRequestDone(Sender : TObject; RqType: >>>>>> THttpRequest; ErrCode : Word); >>>>>> procedure Execute; override; >>>>>> procedure ShowDoc; >>>>>> end; >>>>>> >>>>>> TForm1 = class(TForm) >>>>>> HttpCli1: THttpCli; >>>>>> DoButton: TButton; >>>>>> Memo1: TMemo; >>>>>> procedure DoButtonClick(Sender: TObject); >>>>>> private >>>>>> FWorkerThread : TWorkerThread; >>>>>> end; >>>>>> >>>>>> var >>>>>> Form1: TForm1; >>>>>> >>>>>> implementation >>>>>> >>>>>> {$R *.dfm} >>>>>> >>>>>> procedure TWorkerThread.Execute; >>>>>> begin >>>>>> FHttpCli.ThreadAttach; >>>>>> FHttpCli.MultiThreaded := TRUE; >>>>>> FHttpCli.URL := 'http://localhost'; >>>>>> FHttpCli.RcvdStream := TMemoryStream.Create; >>>>>> FHttpCli.OnRequestDone := HttpCliRequestDone; >>>>>> FHttpCli.GetASync; >>>>>> FHttpCli.MessageLoop; >>>>>> FHttpCli.ThreadDetach; >>>>>> FHttpCli.MultiThreaded := FALSE; >>>>>> end; >>>>>> >>>>>> procedure TWorkerThread.HttpCliRequestDone(Sender : TObject; >>>>>> RqType: THttpRequest; ErrCode : Word); >>>>>> begin >>>>>> FHttpCli.RcvdStream.Seek(0, 0); >>>>>> Synchronize(ShowDoc); >>>>>> FHttpCli.RcvdStream.Free; >>>>>> FHttpCli.RcvdStream := nil; >>>>>> PostMessage(FHttpCli.Handle, WM_QUIT, 0, 0); >>>>>> end; >>>>>> >>>>>> procedure TWorkerThread.ShowDoc; >>>>>> begin >>>>>> Form1.Memo1.Lines.LoadFromStream(FHttpCli.RcvdStream); >>>>>> end; >>>>>> >>>>>> procedure TForm1.DoButtonClick(Sender: TObject); >>>>>> begin >>>>>> HttpCli1.ThreadDetach; >>>>>> FWorkerThread := TWorkerThread.Create(TRUE); >>>>>> FWorkerThread.FreeOnTerminate := TRUE; >>>>>> FWorkerThread.FHttpCli := HttpCli1; >>>>>> FWorkerThread.Resume; >>>>>> end; >>>>>> >>>>>> end. >>>>>> -- >>>>>> [EMAIL PROTECTED] >>>>>> http://www.overbyte.be >>>>>> >>>>>> >>>>>> >>>>>> ----- Original Message ----- >>>>>> From: "Francois PIETTE" <[EMAIL PROTECTED]> >>>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>>> Sent: Monday, June 05, 2006 12:25 PM >>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>>> >>>>>> >>>>>>> Yes, I found the problem. More complex to solve than what I >>>>>>> thought first. >>>>>>> >>>>>>> -- >>>>>>> [EMAIL PROTECTED] >>>>>>> http://www.overbyte.be >>>>>>> >>>>>>> ----- Original Message ----- >>>>>>> From: "Fastream Technologies" <[EMAIL PROTECTED]> >>>>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>>>> Sent: Monday, June 05, 2006 11:37 AM >>>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>>>> >>>>>>> >>>>>>>> Francois, >>>>>>>> >>>>>>>> Have you been able to reproduce the problem there? >>>>>>>> >>>>>>>> Regards, >>>>>>>> >>>>>>>> SZ >>>>>>>> >>>>>>>> ----- Original Message ----- >>>>>>>> From: "Fastream Technologies" <[EMAIL PROTECTED]> >>>>>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>>>>> Sent: Sunday, June 04, 2006 6:24 PM >>>>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>>>>> >>>>>>>> >>>>>>>>> AFAIU, instead of FWindowHandle being defined as window, we now >>>>>>>>> have the >>>>>>>>> entire hierarchy being derived from a Twndcontrol which pools >>>>>>>>> and shares >>>>>>>>> the >>>>>>>>> windows. But I am clueless in terms of this bug as well. I >>>>>>>>> sent a private >>>>>>>>> email to Francois asking for consultancy about this. >>>>>>>>> >>>>>>>>> Thanks anyway, >>>>>>>>> >>>>>>>>> SZ >>>>>>>>> >>>>>>>>> ----- Original Message ----- >>>>>>>>> From: "Arno Garrels" <[EMAIL PROTECTED]> >>>>>>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>>>>>> Sent: Sunday, June 04, 2006 6:06 PM >>>>>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>>>>>> >>>>>>>>> >>>>>>>>>> Fastream Technologies wrote: >>>>>>>>>>> Nothing changes. This is my second answer to this question as >>>>>>>>>>> sometimes my email server gets swamped :(... >>>>>>>>>>> >>>>>>>>>>> I still get the exception even though the package compiles >>>>>>>>>>> with no errors. >>>>>>>>>> >>>>>>>>>> Looks like a bit more complicated. Francois probably knows >>>>>>>>>> better how to fix it, I still haven't fully got the logic of >>>>>>>>>> the new version, sorry. >>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>> Regards, >>>>>>>>>>> >>>>>>>>>>> SZ >>>>>>>>>>> >>>>>>>>>>> ----- Original Message ----- >>>>>>>>>>> From: "Arno Garrels" <[EMAIL PROTECTED]> >>>>>>>>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>>>>>>>> Sent: Sunday, June 04, 2006 5:31 PM >>>>>>>>>>> Subject: Re: [twsocket] ICSv6 Thread Attach/Detach problem >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>>>> Fastream Technologies wrote: >>>>>>>>>>>>> It is used here: >>>>>>>>>>>> >>>>>>>>>>>> Yes I know, but what happens? As Francois already supposed >>>>>>>>>>>> it is in fact redefined and never assigned in >>>>>>>>>>>> TCustomWSocket. >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> --- >>>>>>>>>>>> Arno Garrels [TeamICS] >>>>>>>>>>>> http://www.overbyte.be/eng/overbyte/teamics.html >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> >>>>>>>>>>>> -- >>>>>>>>>>>> To unsubscribe or change your settings for TWSocket mailing >>>>>>>>>>>> list please goto >>>>>>>>>>>> http://www.elists.org/mailman/listinfo/twsocket Visit our >>>>>>>>>>>> website at http://www.overbyte.be >>>>>>>>>> -- >>>>>>>>>> To unsubscribe or change your settings for TWSocket mailing >>>>>>>>>> list please goto >>>>>>>>>> http://www.elists.org/mailman/listinfo/twsocket Visit our >>>>>>>>>> website at http://www.overbyte.be >>>>>>>>> >>>>>>>>> -- >>>>>>>>> To unsubscribe or change your settings for TWSocket mailing >>>>>>>>> list please goto >>>>>>>>> http://www.elists.org/mailman/listinfo/twsocket Visit our >>>>>>>>> website at http://www.overbyte.be >>>>>>>> >>>>>>>> -- >>>>>>>> To unsubscribe or change your settings for TWSocket mailing list >>>>>>>> please goto http://www.elists.org/mailman/listinfo/twsocket >>>>>>>> Visit our website at http://www.overbyte.be >>>>>>> >>>>>>> -- >>>>>>> To unsubscribe or change your settings for TWSocket mailing list >>>>>>> please goto http://www.elists.org/mailman/listinfo/twsocket >>>>>>> Visit our website at http://www.overbyte.be >>>>>> >>>>>> -- >>>>>> To unsubscribe or change your settings for TWSocket mailing list >>>>>> please goto http://www.elists.org/mailman/listinfo/twsocket >>>>>> Visit our website at http://www.overbyte.be >>>>> >>>>> -- >>>>> To unsubscribe or change your settings for TWSocket mailing list >>>>> please goto http://www.elists.org/mailman/listinfo/twsocket >>>>> Visit our website at http://www.overbyte.be >>> -- >>> To unsubscribe or change your settings for TWSocket mailing list >>> please goto http://www.elists.org/mailman/listinfo/twsocket >>> Visit our website at http://www.overbyte.be > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be