Skip to content

TCrossWebSocket - thread-unsafe access to FConnection #146

Open
@havrlisan

Description

@havrlisan

It is possible to open a connection and, before the FConnection is assigned, the status is set to wsConnected. Calling Send raises an AV because of that:

procedure TCrossWebSocket.Send(const AData: string;
  const ACallback: TWsClientCallback);
begin
  if (GetStatus = wsConnected) then
    FConnection.WsSend(AData, ACallback); // FConnection is nil here
end;

Local Variables:
image

This is an issue in a multi-threading environment. My suggestion would be to lock the access to the FConnection field or check if FConnection is assigned. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions