Skip to content
Snippets Groups Projects
Commit 793581e4 authored by Stephen R. van den Berg's avatar Stephen R. van den Berg
Browse files

pgsql: Guard against async destructs.

parent eda1bd2b
No related branches found
No related tags found
No related merge requests found
...@@ -1502,7 +1502,7 @@ class sql_result { ...@@ -1502,7 +1502,7 @@ class sql_result {
return local_backend->call_out(gottimeout, timeout); return local_backend->call_out(gottimeout, timeout);
} }
inline void scuttletimeout(array cid) { inline private void scuttletimeout(array cid) {
if (local_backend) if (local_backend)
local_backend->remove_call_out(cid); local_backend->remove_call_out(cid);
} }
...@@ -1525,6 +1525,8 @@ class sql_result { ...@@ -1525,6 +1525,8 @@ class sql_result {
PD("%O Block for datarow\n", _portalname); PD("%O Block for datarow\n", _portalname);
array cid = setuptimeout(); array cid = setuptimeout();
PT(datarow = datarows->read()); PT(datarow = datarows->read());
if (!this) // If object already destructed, return fast
return 0;
scuttletimeout(cid); scuttletimeout(cid);
if (arrayp(datarow)) if (arrayp(datarow))
return datarow; return datarow;
...@@ -1552,6 +1554,8 @@ class sql_result { ...@@ -1552,6 +1554,8 @@ class sql_result {
if (!sizeof(datarow)) { if (!sizeof(datarow)) {
array cid = setuptimeout(); array cid = setuptimeout();
PT(datarow = datarows->read_array()); PT(datarow = datarows->read_array());
if (!this) // If object already destructed, return fast
return 0;
scuttletimeout(cid); scuttletimeout(cid);
} }
replenishrows(); replenishrows();
...@@ -1595,6 +1599,8 @@ class sql_result { ...@@ -1595,6 +1599,8 @@ class sql_result {
for (;;) { for (;;) {
array cid = setuptimeout(); array cid = setuptimeout();
PT(datarow = datarows->read()); PT(datarow = datarows->read());
if (!this) // If object already destructed, return fast
return 0;
scuttletimeout(cid); scuttletimeout(cid);
if (!arrayp(datarow)) if (!arrayp(datarow))
break; break;
...@@ -1624,6 +1630,8 @@ class sql_result { ...@@ -1624,6 +1630,8 @@ class sql_result {
for (;;) { for (;;) {
array cid = setuptimeout(); array cid = setuptimeout();
PT(datarow = datarows->read_array()); PT(datarow = datarows->read_array());
if (!this) // If object already destructed, return fast
return 0;
scuttletimeout(cid); scuttletimeout(cid);
if (!datarow || !arrayp(datarow[-1])) if (!datarow || !arrayp(datarow[-1]))
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment