MXS-1263: Fix timeouts for partially established connections
When the connection timeout was checked for a connection, it assumed that only valid and fully established sessions should be timed out. Taking into account the fact that connections can be idle even before the session is fully established, the check should be expanded to all connections regardless of the session state.
This commit is contained in:
@ -214,6 +214,7 @@ dcb_alloc(dcb_role_t role, SERV_LISTENER *listener)
|
|||||||
dcb_initialize(newdcb);
|
dcb_initialize(newdcb);
|
||||||
newdcb->dcb_role = role;
|
newdcb->dcb_role = role;
|
||||||
newdcb->listener = listener;
|
newdcb->listener = listener;
|
||||||
|
newdcb->last_read = hkheartbeat;
|
||||||
|
|
||||||
return newdcb;
|
return newdcb;
|
||||||
}
|
}
|
||||||
@ -634,6 +635,7 @@ dcb_connect(SERVER *server, MXS_SESSION *session, const char *protocol)
|
|||||||
pthread_self(), dcb);
|
pthread_self(), dcb);
|
||||||
dcb->persistentstart = 0;
|
dcb->persistentstart = 0;
|
||||||
dcb->was_persistent = true;
|
dcb->was_persistent = true;
|
||||||
|
dcb->last_read = hkheartbeat;
|
||||||
return dcb;
|
return dcb;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3385,14 +3387,22 @@ void dcb_process_idle_sessions(int thr)
|
|||||||
{
|
{
|
||||||
if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER)
|
if (dcb->dcb_role == DCB_ROLE_CLIENT_HANDLER)
|
||||||
{
|
{
|
||||||
MXS_SESSION *session = dcb->session;
|
ss_dassert(dcb->listener);
|
||||||
|
SERVICE *service = dcb->listener->service;
|
||||||
|
|
||||||
if (session->service && session->client_dcb &&
|
if (service->conn_idle_timeout && dcb->state == DCB_STATE_POLLING)
|
||||||
session->client_dcb->state == DCB_STATE_POLLING &&
|
|
||||||
session->service->conn_idle_timeout &&
|
|
||||||
hkheartbeat - session->client_dcb->last_read > session->service->conn_idle_timeout * 10)
|
|
||||||
{
|
{
|
||||||
poll_fake_hangup_event(dcb);
|
int64_t idle = hkheartbeat - dcb->last_read;
|
||||||
|
int64_t timeout = service->conn_idle_timeout * 10;
|
||||||
|
|
||||||
|
if (idle > timeout)
|
||||||
|
{
|
||||||
|
MXS_WARNING("Timing out '%s'@%s, idle for %.1f seconds",
|
||||||
|
dcb->user ? dcb->user : "<unknown>",
|
||||||
|
dcb->remote ? dcb->remote : "<unknown>",
|
||||||
|
(float)idle / 10.f);
|
||||||
|
poll_fake_hangup_event(dcb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user