Fix lack of declaration for session_unlink_dcb; restructure dcb closedown logic to fix counting problem and reduce code.

This commit is contained in:
counterpoint 2015-07-21 09:53:52 +01:00
parent 3c999cef8d
commit c33f1199d9
2 changed files with 23 additions and 30 deletions

View File

@ -1836,27 +1836,7 @@ dcb_close(DCB *dcb)
if ((dcb->state == DCB_STATE_POLLING && !dcb_maybe_add_persistent(dcb))
|| (dcb->state == DCB_STATE_LISTENING))
{
poll_remove_dcb(dcb);
/*
* Return will always be 0 or function will have crashed, so we
* threw away return value.
*/
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,
"%lu [dcb_close] Removed dcb %p in state %s from "
"poll set.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
/**
* close protocol and router session
*/
if (dcb->func.close != NULL)
{
dcb->func.close(dcb);
}
/** Call possible callback for this DCB in case of close */
dcb_call_callback(dcb, DCB_REASON_CLOSE);
dcb_close_finish(dcb);
}
}
@ -1940,22 +1920,34 @@ dcb_maybe_add_persistent(DCB *dcb)
static void
dcb_close_finish(DCB *dcb)
{
/**
* check persistent list, close protocol and router session
poll_remove_dcb(dcb);
/*
* Return will always be 0 or function will have crashed, so we
* threw away return value.
*/
LOGIF(LD, (skygw_log_write(
LOGFILE_DEBUG,"
"%lu [dcb_close] Removed dcb %p in state %s from poll set.",
pthread_self(),
dcb,
STRDCBSTATE(dcb->state))));
/**
* Do a consistency check, then adjust counter if not from persistent pool
*/
if (dcb->func.close)
{
dcb->func.close(dcb);
}
if (dcb->server)
{
if (dcb->server->persistent) CHK_DCB(dcb->server->persistent);
if (0 == dcb->persistentstart) atomic_add(&dcb->server->stats.n_current, -1);
}
/**
* close protocol and router session
*/
if (dcb->func.close != NULL)
{
dcb->func.close(dcb);
}
/** Call possible callback for this DCB in case of close */
dcb_call_callback(dcb, DCB_REASON_CLOSE);
/** Must be DCB_STATE_NOPOLLING when this function is called */
dcb_close(dcb);
}
/**
@ -2847,8 +2839,8 @@ dcb_persistent_clean_count(DCB *dcb, bool cleanall)
while (disposals)
{
nextdcb = disposals->nextpersistent;
poll_remove_dcb(disposals);
dcb_close_finish(disposals);
dcb_close(disposals);
disposals = nextdcb;
}
}

View File

@ -174,6 +174,7 @@ void dprintSession(struct dcb *, SESSION *);
void dListSessions(struct dcb *);
char *session_state(int);
bool session_link_dcb(SESSION *, struct dcb *);
int session_unlink_dcb(SESSION*, DCB*);
SESSION* get_session_by_router_ses(void* rses);
void session_enable_log(SESSION* ses, logfile_id_t id);
void session_disable_log(SESSION* ses, logfile_id_t id);