diff --git a/server/core/dcb.cc b/server/core/dcb.cc index 1ec583e3e..ad81b8d8c 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -389,11 +389,8 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol) /** * Link dcb to session. Unlink is called in dcb_final_free */ - if (!session_link_dcb(session, dcb)) - { - dcb_close(dcb); - return NULL; - } + session_link_dcb(session, dcb); + MXS_DEBUG("Reusing a persistent connection, dcb %p", dcb); dcb->persistentstart = 0; dcb->was_persistent = true; @@ -441,11 +438,8 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol) /** * Link dcb to session. Unlink is called in dcb_final_free */ - if (!session_link_dcb(session, dcb)) - { - dcb_final_free(dcb); - return NULL; - } + session_link_dcb(session, dcb); + fd = dcb->func.connect(dcb, server, session); if (fd == DCBFD_CLOSED) diff --git a/server/core/maxscale/session.h b/server/core/maxscale/session.h index e70bde3bd..a8101d0db 100644 --- a/server/core/maxscale/session.h +++ b/server/core/maxscale/session.h @@ -42,7 +42,14 @@ typedef enum int session_isvalid(MXS_SESSION *); const char *session_state(mxs_session_state_t); -bool session_link_dcb(MXS_SESSION *, struct dcb *); + +/** + * Link a session to a DCB. + * + * @param session The session to link with the dcb + * @param dcb The DCB to be linked + */ +void session_link_dcb(MXS_SESSION *session, struct dcb *dcb); RESULTSET *sessionGetList(SESSIONLISTFILTER); diff --git a/server/core/session.cc b/server/core/session.cc index 972f04f0e..2503b056e 100644 --- a/server/core/session.cc +++ b/server/core/session.cc @@ -13,19 +13,6 @@ /** * @file session.c - A representation of the session within the gateway. - * - * @verbatim - * Revision History - * - * Date Who Description - * 17/06/13 Mark Riddoch Initial implementation - * 02/09/13 Massimiliano Pinto Added session refcounter - * 29/05/14 Mark Riddoch Addition of filter mechanism - * 23/08/15 Martin Brampton Tidying; slight improvement in safety - * 17/09/15 Martin Brampton Keep failed session in existence - leave DCBs to close - * 27/06/16 Martin Brampton Amend to utilise list manager - * - * @endverbatim */ #include @@ -327,28 +314,16 @@ session_set_dummy(DCB *client_dcb) return session; } -/** - * Link a session to a DCB. - * - * @param session The session to link with the dcb - * @param dcb The DCB to be linked - * @return True if the session was sucessfully linked to the DCB - */ -bool -session_link_dcb(MXS_SESSION *session, DCB *dcb) +void session_link_dcb(MXS_SESSION *session, DCB *dcb) { ss_info_dassert(session->state != SESSION_STATE_FREE, "If session->state is SESSION_STATE_FREE then this attempt to " "access freed memory block."); - if (session->state == SESSION_STATE_FREE) - { - return false; - } + atomic_add(&session->refcount, 1); dcb->session = session; /** Move this DCB under the same thread */ dcb->poll.thread.id = session->client_dcb->poll.thread.id; - return true; } /**