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

syscall: refactor OsSysCalls for deeper errno latching #4111

Merged
merged 3 commits into from
Aug 13, 2018

Conversation

venilnoronha
Copy link
Member

Description:
This PR refactors OsSysCalls for deeper errno latching. See #3819 for more information.

  • Introduce SysCallIntResult, SysCallSizeResult and SysCallPtrResult
  • Refactor OsSysCalls routines to return appropriate SysCallResult types

Signed-off-by: Venil Noronha veniln@vmware.com

Risk Level: Low
Testing: Existing tests suffice
Docs Changes: N/A
Release Notes: N/A

* Introduce SysCallIntResult, SysCallSizeResult and SysCallPtrResult
* Refactor OsSysCalls routines to return appropriate SysCallResult types

Signed-off-by: Venil Noronha <veniln@vmware.com>
Signed-off-by: Venil Noronha <veniln@vmware.com>
@mattklein123 mattklein123 self-assigned this Aug 11, 2018
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a really great change.

throw EnvoyException("failed to read proxy protocol (no bytes avail)");
}
if (bytes_avail == 0) {
return false;
}
bytes_avail = std::min(size_t(bytes_avail), sizeof(buf_));
bytes_avail = std::min(size_t(bytes_avail), proxy_protocol_header_.value().extensions_length_);
ssize_t nread = os_syscalls.recv(fd, buf_, bytes_avail, 0);
const Api::SysCallSizeResult result = os_syscalls.recv(fd, buf_, bytes_avail, 0);
ssize_t nread = result.rc_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we nee the ssize_t local var here? Same elsewhere in this function? Is a similar simplification available any other places that I didn't notice?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought it'd keep the code more readable. I can simplify it here and at other places if required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably drop the local variables where possible, but I don't feel that strongly about it. (I think the code would stay readable as long as the return value variable name is readable).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've addressed this in b372000. Note that nread is also used for further manipulations as seen here, so you might still see a few local ssize_t variables in such cases.

Signed-off-by: Venil Noronha <veniln@vmware.com>
Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, very nice!

@mattklein123 mattklein123 merged commit 0a4bffc into envoyproxy:master Aug 13, 2018
snowp added a commit to snowp/envoy that referenced this pull request Aug 14, 2018
* origin/master: (38 commits)
  test: add tests for corner-cases around sending requests before run() starts or after run() ends. (envoyproxy#4114)
  perf: reduce the memory usage of LC Trie construction (envoyproxy#4117)
  test: moving redundant code in websocket_integration_test to utilities (envoyproxy#4127)
  test: make YamlLoadFromStringFail less picky about error msg. (envoyproxy#4141)
  rbac: add rbac network filter. (envoyproxy#4083)
  fuzz: route lookup and header finalization fuzzer. (envoyproxy#4116)
  Set content-type and content-length (envoyproxy#4113)
  fault: use FractionalPercent for percent (envoyproxy#3978)
  test: Fix inverted exact match logic in IntegrationTcpClient::waitForData() (envoyproxy#4134)
  Added cluster_name to load assignment config for static cluster (envoyproxy#4123)
  ssl: refactor ContextConfig to use TlsCertificateConfig (envoyproxy#4115)
  syscall: refactor OsSysCalls for deeper errno latching (envoyproxy#4111)
  thrift_proxy: fix oneway bugs (envoyproxy#4025)
  Do not crash when converting YAML to JSON fails (envoyproxy#4110)
  config: allow unknown fields flag (take 2) (envoyproxy#4096)
  Use a jittered backoff strategy for handling HdsDelegate stream/connection failures (envoyproxy#4108)
  bazel: use GCS remote cache (envoyproxy#4050)
  Add thread local cache of overload action states (envoyproxy#4090)
  Added TCP healthcheck capabilities to the HdsDelegate (envoyproxy#4079)
  secret: add secret provider interface and use it for TlsCertificates (envoyproxy#4086)
  ...

Signed-off-by: Snow Pettersen <snowp@squareup.com>
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

Successfully merging this pull request may close these issues.

None yet

2 participants