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

WebSocketConnection mem leak #16

Open
Trolldemorted opened this issue Jun 15, 2018 · 0 comments
Open

WebSocketConnection mem leak #16

Trolldemorted opened this issue Jun 15, 2018 · 0 comments

Comments

@Trolldemorted
Copy link

  @Override
  public synchronized void onMessage(WebSocket webSocket, ByteString payload) {
    Log.w(TAG, "WSC onMessage()");
    try {
      WebSocketMessage message = WebSocketMessage.parseFrom(payload.toByteArray());

      Log.w(TAG, "Message Type: " + message.getType().getNumber());

      if (message.getType().getNumber() == WebSocketMessage.Type.REQUEST_VALUE)  {
        incomingRequests.add(message.getRequest());
      } else if (message.getType().getNumber() == WebSocketMessage.Type.RESPONSE_VALUE) {
        SettableFuture<Pair<Integer, String>> listener = outgoingRequests.get(message.getResponse().getId());
        if (listener != null) listener.set(new Pair<>(message.getResponse().getStatus(),
                                                      new String(message.getResponse().getBody().toByteArray())));
      }

      notifyAll();
    } catch (InvalidProtocolBufferException e) {
      Log.w(TAG, e);
}

Whenever we send a message it gets added to outgoingRequests, so that the settable future can be fulfilled when confirmation arrives. However, even if it does, the reference to the future is not removed from the map, that only happens in onClosed - which I assume does not happen frequently when the ws connection is permanently open, e.g. in signal-cli in debus mode or Signal-Android without play services (?).

cc @golf1052 @mitchcapper our libsignal is affected by this issue as well

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