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

Fixes #458 #481

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions include/mqtt/async_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ class async_client : public client<Socket, PacketIdBytes> {
void unsuback() = delete;

protected:
// Ensure that only code that knows the *exact* type of an object
// inheriting from this abstract base class can destruct it.
// This avoids issues of the destructor not triggering destruction
// of derived classes, and any member variables contained in them.
// Note: Not virtual to avoid need for a vtable when possible.
~async_client() = default;

async_client(
as::io_context& ioc,
Expand Down
8 changes: 8 additions & 0 deletions include/mqtt/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,14 @@ class client : public endpoint<std::mutex, std::lock_guard, PacketIdBytes> {
if (ping_duration_ms_ != 0) tim_ping_.cancel();
}

protected:
// Ensure that only code that knows the *exact* type of an object
// inheriting from this abstract base class can destruct it.
// This avoids issues of the destructor not triggering destruction
// of derived classes, and any member variables contained in them.
// Note: Not virtual to avoid need for a vtable when possible.
~client() = default;

private:
std::shared_ptr<Socket> socket_;
as::io_context& ioc_;
Expand Down
6 changes: 6 additions & 0 deletions include/mqtt/sync_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ class sync_client : public client<Socket, PacketIdBytes> {
void async_unsuback() = delete;

protected:
// Ensure that only code that knows the *exact* type of an object
// inheriting from this abstract base class can destruct it.
// This avoids issues of the destructor not triggering destruction
// of derived classes, and any member variables contained in them.
// Note: Not virtual to avoid need for a vtable when possible.
~sync_client() = default;

sync_client(
as::io_context& ioc,
Expand Down