HomePhabricator
Diffusion Comm 70ebd47b4563

[services] Tunnelbroker - Fix calling blocking C++ function from an async task

Description

[services] Tunnelbroker - Fix calling blocking C++ function from an async task

Summary:
This diff fixes the calling of the blocking C++ function from an async Tokio task. Without this fix the scheduler first will run the blocking C++ function in a loop and put the async tasks in a queue after the blocking functions in a c++ thread. This causes an issue where the mpsc receiver will invoke a calling function only when the buffer size + 1 instead of on every push to the mpsc channel. As a result, the Tonic server will send messages to the stream only when the buffer size + 1 instead of every new message.

Full context in a linear task: ENG-3065

Test Plan:

  1. Start the Tunnelbroker server.
  2. Using gRPC client (i.e. BloomRPC) connect to the Tunnelbroker messages stream as a client 1.
  3. Using gRPC client (i.e. BloomRPC) connect to the Tunnelbroker messages stream as a client 2 in a separate tab.
  4. Send one message to client 2 from client 1.
  5. Client 2 will receive the message from client 1 in the messages stream.

Without this fix, the client will receive messages by two (mpsc buffer size + 1).

Reviewers: jon, varun, bartek

Reviewed By: varun, bartek

Subscribers: ashoat, tomek, atul

Differential Revision: https://phab.comm.dev/D6843

Details

Provenance
maxAuthored on Feb 23 2023, 3:36 AM
Reviewer
varun
Differential Revision
D6843: [services] Tunnelbroker - Fix calling blocking C++ function from an async task
Parents
rCOMM0f81d4aa56d4: Make types exact
Branches
Unknown
Tags
Unknown