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

Make client requests non blocking #24

Open
UsualSpec opened this issue Sep 19, 2024 · 4 comments
Open

Make client requests non blocking #24

UsualSpec opened this issue Sep 19, 2024 · 4 comments

Comments

@UsualSpec
Copy link
Collaborator

UsualSpec commented Sep 19, 2024

while (serverApiStream->Read(&sRequest)) {

is executed in one thread only. To allow responsiveness, we should rewrite the code such that we execute management functionality in a separate/separate threads. Then the client remains responsive for new commands from the server and can already start them if possible. This could fix #23 potentially.

Suggestion:

  1. If a new sRequest arrives, put it into a commands queue
  2. In another thread consume the queue and issue the respective function in a separate thread.
  3. Send response to server
@romain-jacob
Copy link
Contributor

Somewhat related: why do we send a request to the client in order to get the IP? Why not simply save the IP in the database when the client registers to the server? Sounds like it would be a lot simpler, no?

And if the IP changes, the client would anyway register again to the server I suppose, since changing IP address (almost always) implies we lost network connectivity. Or am I missing something?

@UsualSpec
Copy link
Collaborator Author

Ok. Checkout #29
This could be a fix. We're using boost now.
I tested it and it seems to work. However as it introduces concurrency now, this could introduce concurrency bugs. I wrote the client to be thread safe, but there could be oversights.

@romain-jacob
Copy link
Contributor

Okay. I don't have the competence to judge by just looking at it if that makes sense. I trust you to keep testing until you're confident it can be merged.

@UsualSpec
Copy link
Collaborator Author

Another thing (no need to respond, just for documentation).
https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-TRIGGER-EXAMPLE --> using a trigger to create an entry in the clients and measurement tables if necessary.

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

2 participants