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

fix(rest): support rewinds in libcurl #11709

Merged

Conversation

coryan
Copy link
Member

@coryan coryan commented May 23, 2023

This fixes problems I introduced in the first PR.

See #11703. Really fixes #11167


This change is Reviewable

This fixes problems I introduced in the first PR.
@coryan coryan marked this pull request as ready for review May 23, 2023 17:28
@coryan coryan requested a review from a team as a code owner May 23, 2023 17:28
@codecov
Copy link

codecov bot commented May 23, 2023

Codecov Report

Patch coverage: 95.52% and project coverage change: +0.01 🎉

Comparison is base (80a8b19) 83.02% compared to head (3abc612) 83.03%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11709      +/-   ##
==========================================
+ Coverage   83.02%   83.03%   +0.01%     
==========================================
  Files        1827     1830       +3     
  Lines      164734   164764      +30     
==========================================
+ Hits       136765   136809      +44     
+ Misses      27969    27955      -14     
Impacted Files Coverage Δ
google/cloud/internal/curl_impl.cc 89.43% <75.00%> (+2.38%) ⬆️
google/cloud/internal/curl_writev.cc 93.33% <93.33%> (ø)
google/cloud/internal/curl_writev.h 100.00% <100.00%> (ø)
google/cloud/internal/curl_writev_test.cc 100.00% <100.00%> (ø)

... and 8 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@scotthart scotthart left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @coryan)


google/cloud/internal/curl_writev.h line 57 at r1 (raw file):

    }
    return avail - dst.size();
  }

nit: Should these method implementations be moved to the new .cc file or is there an advantage to leaving them here in the .h?

Code quote:

  explicit WriteVector(std::vector<absl::Span<char const>> v)
      : original_(std::move(v)), writev_(original_.begin(), original_.end()) {}

  std::size_t size() const {
    std::size_t size = 0;
    for (auto const& s : writev_) {
      size += s.size();
    }
    return size;
  }

  std::size_t MoveTo(absl::Span<char> dst) {
    auto const avail = dst.size();
    while (!writev_.empty()) {
      auto& src = writev_.front();
      if (src.size() > dst.size()) {
        std::copy(src.begin(), src.begin() + dst.size(), dst.begin());
        src.remove_prefix(dst.size());
        dst.remove_prefix(dst.size());
        break;
      }
      std::copy(src.begin(), src.end(), dst.begin());
      dst.remove_prefix(src.size());
      writev_.pop_front();
    }
    return avail - dst.size();
  }

GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN

bool WriteVector::Seek(std::size_t offset, int origin) {
// libcurl claims to only req
Copy link
Collaborator

Choose a reason for hiding this comment

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

Incomplete comment?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Member Author

@coryan coryan left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 7 files reviewed, 1 unresolved discussion (waiting on @devbww and @scotthart)


google/cloud/internal/curl_writev.h line 57 at r1 (raw file):

Previously, scotthart (Scott Hart) wrote…

nit: Should these method implementations be moved to the new .cc file or is there an advantage to leaving them here in the .h?

Done.

@coryan coryan enabled auto-merge (squash) May 23, 2023 20:02
@coryan coryan merged commit 5e88b3f into googleapis:main May 23, 2023
59 of 60 checks passed
@coryan coryan deleted the fix-rest-support-rewinds-in-libcurl-take2 branch May 23, 2023 20:50
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.

storage: Send failed since rewinding of the data stream failed
3 participants