Hello,
Our multi-threaded web server leaks 16-32KB per socket now. I hacked a lot
to make async ICS a MT web server but there has been many issues as ICS has
no MT web server example. Note that this leak cannot be catched by
CodeGuard.
I hope we can figure this out together. Up to triggerSessionclosed,
everything is as usual except that in onconnect, a message is sent to the
worker thread that only does:
clientObject->ThreadAttach();
which works fine.
Now the problem starts here:
void __fastcall httpServerClientClass::WndProc(TMessage &msg)
{
if(msg.Msg == WM_HTTP_CLIENT_THREAD_DETACH)
{
httpServerClientClass *clientObject =
(httpServerClientClass*)(void*)msg.WParam;
clientObject->serverThread->HTTPServerClientDisconnected(NULL,
clientObject, msg.LParam);
clientObject->ThreadDetach();
FCloseInvoked = false;
setState(wsInvalidState);
PostThreadMessage(serverThread->ThreadID,
WM_DESTROY_HTTP_CLIENT, (WPARAM)clientObject, 0);
}
else
THttpConnection::WndProc(msg);
}
//---------------------------------------------------------------------------
void __fastcall httpServerClientClass::TriggerSessionClosed(WORD ErrCode)
{
if(!FSessionClosedFlag)
{
FSessionClosedFlag = true;
OnDataSent = NULL;
setOnDataAvailableToNULL();
endOfResponse();
setState(wsClosed);
TCustomLineWSocket::TriggerSessionClosed(ErrCode);
PostMessage(Handle, WM_HTTP_CLIENT_THREAD_DETACH,
(WPARAM)this, ErrCode);
}
}
//---------------------------------------------------------------------------
What I am trying to avoid by setting FState = wsClosed in trigger.. is to
stop the close() routine called after trigger... being executed after the
WM_HTTP_CLIENT_THREAD_DETACH because everything must be in exact order. If I
do not set state to wsinvalidstate or anything other than wsclosed, then the
window is leaked. Oops, I almost forgot to show you the
WM_DESTROY_HTTP_CLIENT:
case WM_DESTROY_HTTP_CLIENT:
{
httpServerClientClass *client =
(httpServerClientClass*)(void*)msg.wParam;
client->ThreadAttach();
delete client;
break;
}
I have been working on this bug since Friday and it is very annoying so hope
you can help me!
Best Regards,
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