-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use smart pointer to manage pcfstat object #2177
Conversation
This requires C++11 and s3fs currently only requires C++03. We haven't really talked about this before since C++11's benefits are modest but #1068 has discussion about a library we would like to use which requires C++14. |
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.
We are definitely leaking on error paths, probably in other parts of the code as well. I don't have a strong opposition to this but let's discuss it in the related issue.
Alternatively we could use a |
ba51c80
to
66b0347
Compare
OK, I switched to auto_ptr this time, and we could switch it back to unique_ptr once s3fs adopts c++11 or above. |
Previously pcfstat points to a raw pointer, and it may be leaked if function returned before deleting it. So use smart pointer to automatically release the object. Note that currently s3fs only uses c++03, so we use auto_ptr here, not unique_ptr, which requires c++11. Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (s3fs-fuse#2152)") Signed-off-by: Eryu Guan <eguan@linux.alibaba.com>
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.
Discussing this in #2195. |
#2195 is a better approach but let's wait until we sort out 1.93. |
This prevents a std::auto_ptr warning about not using std::unique_ptr. Remove similar setting from CI configuration. References s3fs-fuse#2177.
@gaul I agree with your opinion. |
Previously pcfstat points to a raw pointer, and it may be leaked if
function returned before deleting it.
So use smart pointer to automatically release the object.
Note that currently s3fs only uses c++03, so we use auto_ptr here, not
unique_ptr, which requires c++11.
Fixes: 6ca5a24 ("Fix two inconsistency issues between stat cache and cache file (#2152)")
Signed-off-by: Eryu Guan eguan@linux.alibaba.com