This is an automated email from the ASF dual-hosted git repository.
absurdfarce pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-cpp-driver.git
The following commit(s) were added to refs/heads/trunk by this push:
new 58da4b30 CASSCPP-3 Crash on Pure virtual function while the destructor
of the Session object is called
58da4b30 is described below
commit 58da4b30bba39f09bd473c86196da7fde8587dfb
Author: absurdfarce <[email protected]>
AuthorDate: Thu Mar 12 14:29:25 2026 -0500
CASSCPP-3 Crash on Pure virtual function while the destructor of the
Session object is called
patch by Bret McGuire; reviewed by Bret McGuire and Yifan Cai
---
src/cluster.cpp | 13 +++++++++++++
src/connection.hpp | 2 +-
src/prepare_host_handler.cpp | 2 --
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/cluster.cpp b/src/cluster.cpp
index 2f672064..49b5b6b0 100644
--- a/src/cluster.cpp
+++ b/src/cluster.cpp
@@ -663,6 +663,19 @@ void Cluster::notify_or_record(const ClusterEvent& event) {
}
}
+// TODO: This function takes a callback because it's called from both the host
up and host add handlers.
+// The usage there is to send appropriate notifications to all other nodes
whether query prep succeeds or
+// not. But that processing isn't really part of what _this_ function is
trying to accomplish; that
+// responsibility really relies with the host up or host add handler itself.
+//
+// A more robust implementation would be to implement the host up and host add
handlers as a combined
+// sequence of ops and then wait on that whole sequence to either complete or
fail. That's a fairly
+// significant change to the current impl, though, so for now just moving the
notifications into
+// the host up/add handlers will be sufficient.
+//
+// Why does any of this matter? Originally we were triggering this callback
on socket close even when
+// we were closing a connection. This link has already been severed (see
CASSCPP-3) but that effort
+// exposed the unnecessary entanglement described above.
bool Cluster::prepare_host(const Host::Ptr& host, const
PrepareHostHandler::Callback& callback) {
if (connection_ && settings_.prepare_on_up_or_add_host) {
PrepareHostHandler::Ptr prepare_host_handler(
diff --git a/src/connection.hpp b/src/connection.hpp
index 51296701..8ed41fbc 100644
--- a/src/connection.hpp
+++ b/src/connection.hpp
@@ -87,7 +87,7 @@ public:
*
* @param connection The closing connection.
*/
- virtual void on_close(Connection* connection) = 0;
+ virtual void on_close(Connection* connection) {}
};
/**
diff --git a/src/prepare_host_handler.cpp b/src/prepare_host_handler.cpp
index 8a03661c..8616fe08 100644
--- a/src/prepare_host_handler.cpp
+++ b/src/prepare_host_handler.cpp
@@ -69,8 +69,6 @@ void PrepareHostHandler::prepare(uv_loop_t* loop, const
ConnectionSettings& sett
}
void PrepareHostHandler::on_close(Connection* connection) {
- callback_(this);
-
dec_ref(); // The event loop is done with this handler
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]