Only store established connections in the pool
If a connection has not been fully established (i.e. authentication has been completed) then it should not be considered as a connection pool candidate.
This commit is contained in:

committed by
Markus Mäkelä

parent
f7b8744460
commit
35de0c392f
@ -44,6 +44,9 @@ struct session;
|
||||
* listen Create a listener for the protocol
|
||||
* auth Authentication entry point
|
||||
* session Session handling entry point
|
||||
* auth_default Default authenticator name
|
||||
* connlimit Maximum connection limit
|
||||
* established Whether connection is fully established
|
||||
* @endverbatim
|
||||
*
|
||||
* This forms the "module object" for protocol modules within the gateway.
|
||||
@ -62,9 +65,10 @@ typedef struct mxs_protocol
|
||||
int32_t (*close)(struct dcb *);
|
||||
int32_t (*listen)(struct dcb *, char *);
|
||||
int32_t (*auth)(struct dcb *, struct server *, struct session *, GWBUF *);
|
||||
int32_t (*session)(struct dcb *, void *);
|
||||
int32_t (*session)(struct dcb *, void *); // TODO: remove this, not used
|
||||
char *(*auth_default)();
|
||||
int32_t (*connlimit)(struct dcb *, int limit);
|
||||
bool (*established)(struct dcb *);
|
||||
} MXS_PROTOCOL;
|
||||
|
||||
/**
|
||||
|
@ -1658,6 +1658,7 @@ static bool
|
||||
dcb_maybe_add_persistent(DCB *dcb)
|
||||
{
|
||||
if (dcb->user != NULL
|
||||
&& (dcb->func.established == NULL || dcb->func.established(dcb))
|
||||
&& strlen(dcb->user)
|
||||
&& dcb->server
|
||||
&& dcb->server->persistpoolmax
|
||||
|
@ -85,7 +85,9 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
cdc_listen, /* Create a listener */
|
||||
NULL, /* Authentication */
|
||||
NULL, /* Session */
|
||||
cdc_default_auth /* default authentication */
|
||||
cdc_default_auth, /* default authentication */
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -81,7 +81,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
NULL, /**< Session */
|
||||
httpd_default_auth, /**< Default authenticator */
|
||||
NULL /**< Connection limit reached */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -77,6 +77,7 @@ static int gw_send_change_user_to_backend(char *dbname,
|
||||
char *user,
|
||||
uint8_t *passwd,
|
||||
MySQLProtocol *conn);
|
||||
static bool gw_connection_established(DCB* dcb);
|
||||
|
||||
/*
|
||||
* The module entry point routine. It is this routine that
|
||||
@ -102,7 +103,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
gw_change_user, /* Authentication */
|
||||
NULL, /* Session */
|
||||
gw_backend_default_auth, /* Default authenticator */
|
||||
NULL /* Connection limit reached */
|
||||
NULL, /* Connection limit reached */
|
||||
gw_connection_established
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
@ -883,7 +885,8 @@ static int gw_MySQLWrite_backend(DCB *dcb, GWBUF *queue)
|
||||
|
||||
CHK_DCB(dcb);
|
||||
|
||||
if (dcb->was_persistent && dcb->state == DCB_STATE_POLLING)
|
||||
if (dcb->was_persistent && dcb->state == DCB_STATE_POLLING &&
|
||||
backend_protocol->protocol_auth_state == MXS_AUTH_STATE_COMPLETE)
|
||||
{
|
||||
ss_dassert(dcb->persistentstart == 0);
|
||||
/**
|
||||
@ -1949,3 +1952,9 @@ gw_send_change_user_to_backend(char *dbname,
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static bool gw_connection_established(DCB* dcb)
|
||||
{
|
||||
MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol;
|
||||
return proto->protocol_auth_state == MXS_AUTH_STATE_COMPLETE;
|
||||
}
|
||||
|
@ -115,7 +115,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /* Authentication */
|
||||
NULL, /* Session */
|
||||
gw_default_auth, /* Default authenticator */
|
||||
gw_connection_limit /* Send error connection limit */
|
||||
gw_connection_limit, /* Send error connection limit */
|
||||
NULL
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -185,7 +185,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
NULL, /**< Session */
|
||||
mxsd_default_auth, /**< Default authenticator */
|
||||
NULL /**< Connection limit reached */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -102,7 +102,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
NULL, /**< Session */
|
||||
telnetd_default_auth, /**< Default authenticator */
|
||||
NULL /**< Connection limit reached */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
Reference in New Issue
Block a user