Ensure DCB for closing session does not become persistent; remove bref_was_not_in_use.

This commit is contained in:
Martin Brampton
2015-09-17 14:38:56 +01:00
parent dc3b0b067b
commit 31c6666278
2 changed files with 14 additions and 4 deletions

View File

@ -1839,6 +1839,15 @@ dcb_close(DCB *dcb)
return;
}
/*
* If DCB is in persistent pool, mark it as an error and exit
*/
if (dcb->persistentstart)
{
dcb->dcb_errhandle_called = true;
return;
}
spinlock_acquire(&zombiespin);
if (!dcb->dcb_is_zombie)
{
@ -1879,6 +1888,8 @@ dcb_maybe_add_persistent(DCB *dcb)
int poolcount = -1;
if (dcb->user != NULL
&& strlen(dcb->user)
&& dcb->session->state != SESSION_STATE_STOPPING
&& dcb->session->state != SESSION_STATE_TO_BE_FREED
&& dcb->server
&& dcb->server->persistpoolmax
&& (dcb->server->status & SERVER_RUNNING)
@ -2817,6 +2828,8 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
|| persistentdcb-> dcb_errhandle_called
|| count >= server->persistpoolmax
|| persistentdcb->server == NULL
|| persistentdcb->session->state == SESSION_STATE_STOPPING
|| persistentdcb->session->state == SESSION_STATE_TO_BE_FREED
|| !(persistentdcb->server->status & SERVER_RUNNING)
|| (time(NULL) - persistentdcb->persistentstart) > server->persistmaxtime)
{
@ -2846,6 +2859,7 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
while (disposals)
{
nextdcb = disposals->nextpersistent;
disposals->persistentstart = 0;
dcb_close_finish(disposals);
dcb_close(disposals);
disposals = nextdcb;

View File

@ -4875,7 +4875,6 @@ static void handleError (
bref = get_bref_from_dcb(rses, backend_dcb);
if (bref != NULL)
{
bool bref_was_in_use = BREF_IS_IN_USE(bref);
CHK_BACKEND_REF(bref);
bref_clear_state(bref, BREF_IN_USE);
bref_set_state(bref, BREF_CLOSED);
@ -4960,7 +4959,6 @@ static void handle_error_reply_client(
*/
if ((bref = get_bref_from_dcb(rses, backend_dcb)) != NULL)
{
bool bref_was_in_use = BREF_IS_IN_USE(bref);
CHK_BACKEND_REF(bref);
bref_clear_state(bref, BREF_IN_USE);
bref_set_state(bref, BREF_CLOSED);
@ -5000,7 +4998,6 @@ static bool handle_error_new_connection(
int max_slave_rlag;
backend_ref_t* bref;
bool succp;
bool bref_was_in_use;
myrses = *rses;
ss_dassert(SPINLOCK_IS_LOCKED(&myrses->rses_lock));
@ -5017,7 +5014,6 @@ static bool handle_error_new_connection(
goto return_succp;
}
CHK_BACKEND_REF(bref);
bref_was_in_use = BREF_IS_IN_USE(bref);
/**
* If query was sent through the bref and it is waiting for reply from