Hello,
In,
procedure TCustomWSocket.Do_FD_CLOSE(var msg: TMessage);
begin
...
ASyncReceive(0, RemoveOption(FComponentOptions, wsoNoReceiveLoop));
if not FCloseInvoked then begin
FCloseInvoked := TRUE;
TriggerSessionClosed(HiWord(msg.LParam));
end;
if FState <> wsClosed then
Close;
end;
end;
We have triggersessionclosed called before a close(). Is this correct? I
need an event which should be called after ALL the messaging ends for the
socket connection object. Because otherwise, I get AVs at socket return to
pool after 10-18 hours of running! I placed my return code postthreadmessage
to both OnSessionclosed and changestate such as,
void __fastcall ReverseProxyClientClass::OnClientChangeState(TObject
*Sender, TSocketState OldState, TSocketState NewState)
{
if(NewState == wsClosed && OldState != wsClosed)
destroyObject(); //posts a message to thread message pump--does NOT
directly destroy!
}
//---------------------------------------------------------------------------
I suspect the below code could be the cause as well:
procedure TCustomWSocket.Dup(NewHSocket : TSocket);
var
iStatus : Integer;
optlen : Integer;
begin
{$IFDEF CLR}
if DesignMode then begin
FHsocket := NewHSocket;
Exit;
end;
{$ENDIF}
if (NewHSocket = 0) or (NewHSocket = INVALID_SOCKET) then begin
WSocket_Synchronized_WSASetLastError(WSAEINVAL);
SocketError('Dup'); // in handler of this, I post message to Abort()
Exit;
end;
if FState <> wsClosed then begin
iStatus := WSocket_Synchronized_closesocket(FHSocket);
FHSocket := INVALID_SOCKET;
if iStatus <> 0 then begin
SocketError('Dup (closesocket)'); // in the handler of this,
I post message to Abort()
Exit;
end;
ChangeState(wsClosed); // in the handler of this, I call
destroyobject, see above.
end;
// if the changestate is called in above line, then I think we have a
problem since the handler can destroy the object!
Where should I call destroyobject? Please help soonest.
Best Regards,
SZ
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be