Ok I can confirm this is the problem (below). There seems to be other messages for the same client in the queue that are processed before the WM_SYNCED so this spoils everything. SendDocument is called before this function ends!!
Any ideas? Thanks, SZ ----- Original Message ----- From: "Fastream Technologies" <[EMAIL PROTECTED]> To: "ICS support mailing" <twsocket@elists.org> Sent: Wednesday, March 22, 2006 10:40 AM Subject: Re: [twsocket] Server problem (leaking memory) > Ok here is the core of the problem: The waitforsinglemessage solution > worked > for the single thread for each connection case but since it is blocking, > cannot be used for the 32 clients per thread proxy. Here is the problem: > > This is the worker thread: > > void __fastcall THTTPThread::processServerThreadMessage(const MSG &msg) > { > if(msg.message == WM_HTTP_CLIENT_THREAD_ATTACH) > { > httpServerClientClass *clientObject = > (httpServerClientClass*)msg.wParam; > > clientObject->ThreadAttach(); > PostThreadMessage(clientObject->serverThread->ThreadID, > WM_SYNCED, (WPARAM)clientObject, 0); > } > ... > } // this function is called for every GetMessage > > And this is the server thread: > > void __fastcall httpServerThread::HTTPServerClientConnected(TObject > *Sender, > TObject *Client, WORD Error) > { > httpServerClientClass *clientObject = > (httpServerClientClass*)Client; > > clientObject->serverPermissions = serverPermissions; > clientObject->FServer = HTTPServer; > clientObject->URLPermissions = > serverPermissions->seekURLPermission(DEFAULTDOMAIN, true); > clientObject->affinityThread = > httpServerClientThreadManager->getHTTPThread(); > > clientObject->ThreadDetach(); > > while(!PostThreadMessage(clientObject->affinityThread->ThreadID, > WM_HTTP_CLIENT_THREAD_ATTACH, (WPARAM)clientObject, 0)) > ::Sleep(1); > > MSG msg; > try > { > while(!Terminated && GetMessage(&msg, NULL, 0, 0)) > { > if(msg.message == WM_SYNCED && msg.wParam == > (WPARAM)clientObject) > break; // NEVER COMES HERE!! > else > processServerThreadMessage(msg); > } > } > catch(ESocketException &e) > { > } > catch(...) > { > } > > //WaitForSingleObject(clientObject->attachedEvent, INFINITE); > > HTTPServerClientPostConnect(clientObject); > } > //--------------------------------------------------------------------------- > > What I want is simple: I first want to have the thread attached before > exiting the function and moreover, I need other client run smoothly. > > Hope you can help. > > Best Regards, > > SZ > > ----- Original Message ----- > From: "Arno Garrels" <[EMAIL PROTECTED]> > To: "ICS support mailing" <twsocket@elists.org> > Sent: Monday, March 20, 2006 10:34 PM > Subject: Re: [twsocket] Server problem (leaking memory) > > >> Arno Garrels wrote: >>> Fastream Technologies wrote: >>>> Ok figured out your logic. It gives the same performance/memory leak as >>>> before. I think there is a problem with another part... >>> >>> This may not be your current problem, but it is a problem. >>> >>>> - destroy the client object fully >>>> - have the FClientList routine run in the listener thread as it is >>>> unprotected! >>>> - Could you advise a shut down destruction routine (Pascal now ok). >>> >>> Currently I've no idea how to do that, but I'm pretty sure it is >>> possible. >>> This stuff is rather tricky, my solution is in TWSocketThrdServer, but >>> of course many other solutions are possible. >> >> Forgot to mention that I would derive a MT TWsocketServer first that >> behaves >> as I like. It often helps a lot to reduce the problem to the basics. >> THttpServer is derived from TWSocketServer. >> >> --- >> Arno Garrels [TeamICS] >> http://www.overbyte.be/eng/overbyte/teamics.html >> >> >>>> >>>> SZ >>>> >>>> ----- Original Message ----- >>>> From: "Fastream Technologies" <[EMAIL PROTECTED]> >>>> To: "ICS support mailing" <twsocket@elists.org> >>>> Sent: Monday, March 20, 2006 6:01 PM >>>> Subject: Re: [twsocket] Server problem (leaking memory) >>>> >>>> >>>>> Hi, >>>>> >>>>> ----- Original Message ----- >>>>> From: "Arno Garrels" <[EMAIL PROTECTED]> >>>>> To: "ICS support mailing" <twsocket@elists.org> >>>>> Sent: Monday, March 20, 2006 4:25 PM >>>>> Subject: Re: [twsocket] Server problem (leaking memory) >>>>> >>>>> >>>>>> Fastream Technologies wrote: >>>>>>>> You say that you post a message to the worker thread to let it >>>>>>>> ThreadAttach. >>>>>>>> What do you do until the worker thread has attached?? You cannot >>>>>>>> just >>>>>>>> post a message, you have to wait until the workerthread has >>>>>>>> allocated >>>>>>>> the >>>>>>>> window. >>>>>>> >>>>>>> What do you suggest? What should I do? Would SendMessage work? But >>>>>>> there is no SendThreadMessage! >>>>>> >>>>>> If you have one thread per connection you post your message, then >>>>>> in a loop check a boolean flag that is set from within the worker >>>>>> thread when ThreadAttach returned. If you have multiple connections >>>>>> per thread you could use messages combined with Windows events or >>>>>> other >>>>>> sync-objects. >>>>>> The latter design is demonstrated with TWSocketThrdServer that I made >>>>>> to test ICS SSL in a multi-threaded environment. One connection per >>>>>> thread >>>>>> is demonstrated in demo ThrdSrv. >>>>> >>>>> I saw your waitformultiplemessages design and it works with attach. >>>>> But >>>>> there is a big problem with detach: In my code, triggersessionclosed >>>>> runs in >>>>> the context of worker thread!!! What I want: >>>>> >>>>> - destroy the client object fully >>>>> - have the FClientList routine run in the listener thread as it is >>>>> unprotected! >>>>> - Could you advise a shut down destruction routine (Pascal now ok). >>>>> >>>>> Thanks, >>>>> >>>>> SZ >>>>> >>>>> -- >>>>> 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