Fixed idle session processing
The current implementation of idle connection timeouts is not safe. The sessions are handled in a way which is not thread-safe and the checking is done from a non-polling thread. With this change, the checks for the session timeouts are done in one of the polling threads in a thread-safe manner only if at least one service has enabled the timing out of idle client connections.
This commit is contained in:
@ -2,10 +2,10 @@
|
||||
#define _HK_HEARTBEAT_H
|
||||
|
||||
/**
|
||||
* The global housekeeper heartbeat value. This value is increamente
|
||||
* every 100ms and may be used for crude timing etc.
|
||||
* The global housekeeper heartbeat value. This value is incremented
|
||||
* every 100 milliseconds and may be used for crude timing etc.
|
||||
*/
|
||||
|
||||
extern unsigned long hkheartbeat;
|
||||
extern long hkheartbeat;
|
||||
|
||||
#endif
|
||||
|
||||
@ -135,6 +135,10 @@ enum
|
||||
|
||||
#define DEFAULT_SSL_CERT_VERIFY_DEPTH 100 /*< The default certificate verification depth */
|
||||
#define SERVICE_MAX_RETRY_INTERVAL 3600 /*< The maximum interval between service start retries */
|
||||
|
||||
/** Value of service timeout if timeout checks are disabled */
|
||||
#define SERVICE_NO_SESSION_TIMEOUT LONG_MAX
|
||||
|
||||
/**
|
||||
* Parameters that are automatically detected but can also be configured by the
|
||||
* user are initially set to this value.
|
||||
@ -180,7 +184,7 @@ typedef struct service
|
||||
SERVICE_REFRESH_RATE rate_limit; /**< The refresh rate limit for users table */
|
||||
FILTER_DEF **filters; /**< Ordered list of filters */
|
||||
int n_filters; /**< Number of filters */
|
||||
int conn_timeout; /*< Session timeout in seconds */
|
||||
long conn_idle_timeout; /**< Session timeout in seconds */
|
||||
ssl_mode_t ssl_mode; /*< one of DISABLED, ENABLED or REQUIRED */
|
||||
char *weightby;
|
||||
struct service *next; /**< The next service in the linked list */
|
||||
|
||||
@ -146,6 +146,13 @@ typedef struct session
|
||||
#endif
|
||||
} SESSION;
|
||||
|
||||
/** Whether to do session timeout checks */
|
||||
extern bool check_timeouts;
|
||||
|
||||
/** When the next timeout check is done. This is compared to hkheartbeat in
|
||||
* hk_heartbeat.h */
|
||||
extern long next_timeout_check;
|
||||
|
||||
#define SESSION_PROTOCOL(x, type) DCB_PROTOCOL((x)->client, type)
|
||||
|
||||
/**
|
||||
@ -184,7 +191,7 @@ int session_unlink_dcb(SESSION*, DCB*);
|
||||
SESSION* get_session_by_router_ses(void* rses);
|
||||
void session_enable_log_priority(SESSION* ses, int priority);
|
||||
void session_disable_log_priority(SESSION* ses, int priority);
|
||||
void session_close_timeouts(void* data);
|
||||
RESULTSET *sessionGetList(SESSIONLISTFILTER);
|
||||
|
||||
void process_idle_sessions();
|
||||
void enable_session_timeouts();
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user