-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
cleanup(libscap): Allow retries after encountering SCAP_EOF #1809
Conversation
return gzread(((reader_handle_t*)r->handle)->m_file, buf, len); | ||
int readsize = gzread(((reader_handle_t*)r->handle)->m_file, buf, len); | ||
|
||
if (readsize < (int)len) |
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.
Can't all of this be handled by the client program?
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 don't think so, at least with the current API. I'm trying to use sinsp::open_savefile() + sinsp::next() to read events from a file which is simultaneously being written by another process. The problem is that EOF handling in zlib is sticky; it changes its internal state when it reaches the end of input which in turn causes subsequent sinsp::next() calls to fail with SCAP_EOF even after more data has been written to the file.
The gzread documentation recommends using gzclearerr in this case. I don't think I can do so from the client side because we don't appear expose the gzFile handle.
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.
Thanks for the clarification, LGTM!
/milestone TBD |
Call gzclearerr if gzread returns fewer bytes than expected. This lets us "tail" a file being written by another process. Signed-off-by: Gerald Combs <gerald@wireshark.org>
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.
/approve
/milestone 0.17.0
LGTM label has been added. Git tree hash: a3841cf57628ac62d83d8928fb0fe41122b1cfcb
|
/milestone TBD |
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: FedeDP, geraldcombs, jasondellaluce The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/milestone 0.17.0 |
Call gzclearerr if gzread returns fewer bytes than expected. This lets us "tail" a file being written by another process.
What type of PR is this?
/kind cleanup
Any specific area of the project related to this PR?
/area libscap-engine-savefile
Does this PR require a change in the driver versions?
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: