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
2d7df3eb89
commit
4117dcf410
@ -43,7 +43,10 @@ struct session;
|
||||
* close MaxScale close entry point for the socket
|
||||
* listen Create a listener for the protocol
|
||||
* auth Authentication entry point
|
||||
* session Session handling 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;
|
||||
|
||||
/**
|
||||
|
@ -1344,6 +1344,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 =
|
||||
|
@ -80,6 +80,7 @@ static int gw_send_change_user_to_backend(char *dbname,
|
||||
static void gw_send_proxy_protocol_header(DCB *backend_dcb);
|
||||
static bool get_ip_string_and_port(struct sockaddr_storage *sa, char *ip, int iplen,
|
||||
in_port_t *port_out);
|
||||
static bool gw_connection_established(DCB* dcb);
|
||||
|
||||
/*
|
||||
* The module entry point routine. It is this routine that
|
||||
@ -105,7 +106,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 =
|
||||
@ -794,7 +796,7 @@ gw_read_and_write(DCB *dcb)
|
||||
* The reply to an ignorable command is in the packet. Extract the
|
||||
* response type and discard the response.
|
||||
*/
|
||||
uint8_t result;
|
||||
uint8_t result = 0xff;
|
||||
gwbuf_copy_data(read_buffer, MYSQL_HEADER_LEN, 1, &result);
|
||||
proto->ignore_replies--;
|
||||
ss_dassert(proto->ignore_replies >= 0);
|
||||
@ -957,7 +959,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);
|
||||
/**
|
||||
@ -1967,3 +1970,9 @@ static bool get_ip_string_and_port(struct sockaddr_storage *sa,
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool gw_connection_established(DCB* dcb)
|
||||
{
|
||||
MySQLProtocol *proto = (MySQLProtocol*)dcb->protocol;
|
||||
return proto->protocol_auth_state == MXS_AUTH_STATE_COMPLETE;
|
||||
}
|
||||
|
@ -102,7 +102,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 =
|
||||
|
@ -183,7 +183,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