Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCrossWebSocket - thread-unsafe access to FConnection #146

Open
havrlisan opened this issue Sep 23, 2024 · 0 comments
Open

TCrossWebSocket - thread-unsafe access to FConnection #146

havrlisan opened this issue Sep 23, 2024 · 0 comments

Comments

@havrlisan
Copy link
Contributor

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant