Insert fake events under a lock

The thread-specific spinlock needs to be acquired before a fake event is
inserted from a non-polling thread. The usual situation is when a monitor
thread inserts a hangup event for a DCB.

Other, less common cases are when session timeouts have been enabled and
the DCB needs to be closed. Here it is better to insert a fake hangup
event instead of directly closing the DCB from an external thread.
This commit is contained in:
Markus Makela
2016-10-25 21:23:39 +03:00
parent 8efdaa1ea6
commit f77f78360e
2 changed files with 37 additions and 7 deletions

View File

@ -42,6 +42,7 @@
#include <maxscale/atomic.h>
#include <maxscale/log_manager.h>
#include <maxscale/housekeeper.h>
#include <maxscale/poll.h>
/* This list of all sessions */
LIST_CONFIG SESSIONlist =
@ -927,7 +928,7 @@ void process_idle_sessions()
if (all_session->service && all_session->client_dcb && all_session->client_dcb->state == DCB_STATE_POLLING &&
hkheartbeat - all_session->client_dcb->last_read > all_session->service->conn_idle_timeout * 10)
{
dcb_close(all_session->client_dcb);
poll_fake_hangup_event(all_session->client_dcb);
}
current = list_iterate(&SESSIONlist, current);