Fix stale async handler after timeout - #224
Conversation
Cancel socket and drain pending handlers before throwing in wait_async(), preventing use-after-free when dialog is copied Fix: karastojko#223, maybe karastojko#222 too
Spixmaster
left a comment
There was a problem hiding this comment.
The CMake issues are critical. Currently, the tests do not even build.
The other stuff is from clang-tidy. You should really use it.
|
Tests are passing on my side. |
|
Issue #222 was not fixed by this. |
- test/CMakeLists.txt: remove unnecessary Boost::system dependency (karastojko#212) - Add explicit on TestServer constructor - Add missing includes: unit_test_suite, tools/old/interface, steady_timer, system/error_code, string - Use explicit curly braces on all if statements - Fix unused return value from socket_->close(ec)
|
All issues in comments have been resolved. Let me know if I missed anything.. |
| @@ -12,12 +12,17 @@ copy at http://www.freebsd.org/copyright/freebsd-license.html. | |||
| #define BOOST_TEST_MODULE dialog_test | |||
|
|
|||
| #include <boost/test/unit_test.hpp> | |||
There was a problem hiding this comment.
#include <boost/test/unit_test.hpp> is not needed.
|
Thank you very much. You can mark the recommendations as resolved when you considered them to distinguish between open and closed recommendations. |
- Remove unused `<boost/asio.hpp>`, add explicit includes - Add missing `<chrono>`, `<string>`, `<cstddef>`, `<boost/assert.hpp>` - Add `const` to `error_code` lambda parameters - Add `explicit` on `TestServer` constructor - Use explicit curly braces on all if statements - Check `socket_->close()` error code with `BOOST_CHECK` instead of
|
Ok, just pushed a new commit with all new comments addressed. |
|
I depends on the configuration file.
This is my current clang-tidy.yaml. ---
# "google-readability-namespace-comments" needs to be removed as it is an alias for "llvm-namespace-comment" and
# thus prevents fixing.
Checks: "*, -abseil-string-find-str-contains, -altera-id-dependent-backward-branch, -altera-unroll-loops, -bugprone-branch-clone,
-bugprone-easily-swappable-parameters, -bugprone-suspicious-missing-comma, -bugprone-unused-raii, -cert-err58-cpp, -cppcoreguidelines-avoid-magic-numbers,
-fuchsia-default-arguments-calls, -fuchsia-default-arguments-declarations, -fuchsia-overloaded-operator, -fuchsia-statically-constructed-objects,
-google-readability-function-size, -google-readability-namespace-comments, -google-readability-todo, -hicpp-function-size,
-hicpp-named-parameter, -hicpp-use-auto, -llvm-else-after-return, -llvm-include-order, -llvmlibc-callee-namespace, -llvmlibc-implementation-in-namespace,
-llvmlibc-inline-function-decl, -llvmlibc-restrict-system-libc-headers, -misc-no-recursion, -modernize-loop-convert, -modernize-use-auto,
-modernize-use-designated-initializers, -modernize-use-nodiscard, -modernize-use-trailing-return-type, -openmp-exception-escape,
-performance-inefficient-string-concatenation, -readability-else-after-return, -readability-function-cognitive-complexity,
-readability-function-size, -readability-identifier-length, -readability-magic-numbers, -readability-named-parameter"
FormatStyle: ${XDG_CONFIG_HOME}/clang/clang-format.yamlIn general, it is useful to integrate linter (gives recommendations) and formatter into your editor. For me, it is Vim. You might be interested in at least the tools here, https://github.com/dense-analysis/ale/blob/master/supported-tools.md, or even the programme itself, https://github.com/dense-analysis/ale. clang-format is my favourite formatter for C++. |
|
I just tested this pull request. normal mailio: my server can send e-mail, my computer cannot this pull request: My computer sent one e-mail. I did not test my server. A good first sign. |
- src/dialog.cpp: suppress bugprone-unused-return-value for socket_->cancel() calls by assigning to std::ignore - test/test_dialog_stale_handler.cpp: use return value of socket_->close() in BOOST_CHECK instead of out-param
|
I am glad. Sent out the fix for the latest comments. Some of them where false positive though. The |
It would be good to include into the repo your clang-tidy.yaml and clang-format.yaml, to prevent going back and forward with PRs |
I have not authority over this project. Linter and formatter are something the owner decides. |
|
I have never seen |
|
The 0.26 is released, so I will take a look of this. Thanks for the effort. |
Cancel socket and drain pending handlers before throwing in wait_async(), preventing use-after-free when dialog is copied
Fix: #223, maybe #222 too