-
Notifications
You must be signed in to change notification settings - Fork 800
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
jsonrpc: Wait for the socket to be ready to read. #11815
base: master
Are you sure you want to change the base?
Conversation
We found out that sometimes we hit a busy loop here, so adding a timeout to make sure we do not hangup forever here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. I'll let a non-Yahoo reviewer chime in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is correct. Should you call read_ready if there were some bytes read in previous iterations of the outer loop? Shouldn't a timeout from read_ready stop the inner loop? It seems like this will always wait until EOF or until (timeout_ms * attempts) have elapsed. The logic is a bit confusing, so maybe some comments about what is happening will clear it up.
@@ -30,12 +30,12 @@ | |||
#include "shared/rpc/MessageStorage.h" | |||
#include <tscore/ink_assert.h> | |||
#include <tscore/ink_sock.h> | |||
|
|||
#include <iostream> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This header is unused.
@@ -117,23 +117,36 @@ IPCSocketClient ::send(std::string_view data) | |||
} | |||
|
|||
IPCSocketClient::ReadStatus | |||
IPCSocketClient::read_all(std::string &content) | |||
IPCSocketClient::read_all(std::string &content, std::chrono::milliseconds timeout_ms, int attempts) | |||
{ | |||
if (this->is_closed()) { | |||
// we had a failure. | |||
return {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know it's not part of the changes, but this will return NO_ERROR
? But the comment indicates a failure. Could UNKNOWN
be a better return?
// done! | ||
break; | ||
} | ||
} while (ret != 0 && attempts_left > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this check for readStatus timeout and error and also stop the loop? If you don't check for timeout, this function will wait for timeout_ms * attempts (10 seconds by default). What errors would poll return that we would want to retry?
We found out that sometimes we hit a busy loop here, so adding a timeout to make sure we do not hangup forever here.