File tree Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Expand file tree Collapse file tree 3 files changed +47
-6
lines changed Original file line number Diff line number Diff line change @@ -1066,6 +1066,20 @@ class internal::BaseResult::Impl
1066
1066
delete m_reply;
1067
1067
}
1068
1068
1069
+ /*
1070
+ Discard the CDK reply object owned by the implementation. This
1071
+ is called when the corresponding session is about to be closed
1072
+ and the reply object will be no longer valid.
1073
+ */
1074
+
1075
+ void discard_reply ()
1076
+ {
1077
+ if (!m_reply)
1078
+ return ;
1079
+
1080
+ delete m_reply;
1081
+ m_reply = NULL ;
1082
+ }
1069
1083
1070
1084
/*
1071
1085
Read next row from the cursor. Returns NULL if there are no
@@ -1271,7 +1285,7 @@ internal::BaseResult::BaseResult(XSession_base *sess,
1271
1285
internal::BaseResult::~BaseResult ()
1272
1286
{
1273
1287
try {
1274
- if (m_sess)
1288
+ if (m_sess && m_sess-> m_impl )
1275
1289
m_sess->deregister_result (this );
1276
1290
}
1277
1291
catch (...) {}
@@ -1322,6 +1336,30 @@ internal::BaseResult::get_impl() const
1322
1336
}
1323
1337
1324
1338
1339
+ /*
1340
+ This method is called when the result object is deregistered from
1341
+ the session (so that it is no longer the active result of that
1342
+ session).
1343
+
1344
+ We do cleanups here to make the result object independent from the
1345
+ session. Derived classes should cache pending results so that they
1346
+ can be accessed without the session.
1347
+ */
1348
+
1349
+ void internal::BaseResult::deregister_notify ()
1350
+ {
1351
+ assert (m_impl);
1352
+
1353
+ // Let derived object do its own cleanup
1354
+ deregister_cleanup ();
1355
+
1356
+ // Discard CDK reply object which is about to be invalidated.
1357
+ m_impl->discard_reply ();
1358
+
1359
+ m_sess = NULL ;
1360
+ }
1361
+
1362
+
1325
1363
unsigned
1326
1364
internal::BaseResult::getWarningCount () const
1327
1365
{
Original file line number Diff line number Diff line change @@ -280,11 +280,12 @@ void internal::XSession_base::rollback()
280
280
void internal::XSession_base::close ()
281
281
{
282
282
try {
283
+
284
+ // Results should cache their data before deleting the implementation.
285
+ register_result (NULL );
286
+
283
287
if (m_master_session)
284
288
{
285
- // Results should cache their data before deleting the implementation.
286
- register_result (NULL );
287
-
288
289
// Notify NodeSession nodes that master is being removed.
289
290
for (auto node : m_impl->m_nodes )
290
291
{
Original file line number Diff line number Diff line change @@ -313,7 +313,9 @@ namespace internal {
313
313
}
314
314
315
315
316
- virtual void deregister_notify (){}
316
+ virtual void deregister_cleanup () {}
317
+
318
+ void deregister_notify ();
317
319
318
320
public:
319
321
@@ -792,7 +794,7 @@ class PUBLIC_API RowResult
792
794
m_cache = false ;
793
795
}
794
796
795
- void deregister_notify () override
797
+ void deregister_cleanup () override
796
798
{
797
799
// cache elements
798
800
count ();
You can’t perform that action at this time.
0 commit comments