Moved the housekeeper heartbeat to a separate header for ease of integration.
This keeps the behavior the same but allows the heartbeat to be used as a crude timer without including everything the housekeeper.h header includes. Moved the protocol level updates on the DCBs last_read value into dcb_read. This keeps the implementation nice and compact.
This commit is contained in:
@ -70,6 +70,7 @@
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
#include <hashtable.h>
|
||||
#include <hk_heartbeat.h>
|
||||
|
||||
/** Defined in log_manager.cc */
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
@ -816,6 +817,9 @@ int dcb_read(
|
||||
n = 0;
|
||||
goto return_n;
|
||||
}
|
||||
|
||||
dcb->last_read = hkheartbeat;
|
||||
|
||||
bufsize = MIN(b, MAX_BUFFER_SIZE);
|
||||
|
||||
if ((buffer = gwbuf_alloc(bufsize)) == NULL)
|
||||
|
@ -98,22 +98,31 @@ hkinit();
|
||||
skygw_log_sync_all();
|
||||
ss_info_dassert(0 != result, "Start all should succeed");
|
||||
|
||||
ss_dfprintf(stderr, "\t..done\nTiming out a session.");
|
||||
service->conn_timeout = 1;
|
||||
dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);
|
||||
ss_info_dassert(dcb != NULL, "DCB allocation failed");
|
||||
ss_dfprintf(stderr, "\t..done\nTiming out a session.");
|
||||
|
||||
session = session_alloc(service,dcb);
|
||||
ss_info_dassert(session != NULL, "Session allocation failed");
|
||||
session->client->state = DCB_STATE_POLLING;
|
||||
session->client->func.hangup = hup;
|
||||
sleep(30);
|
||||
service->conn_timeout = 1;
|
||||
result = serviceStart(service);
|
||||
skygw_log_sync_all();
|
||||
ss_info_dassert(0 != result, "Start should succeed");
|
||||
result = serviceStop(service);
|
||||
skygw_log_sync_all();
|
||||
ss_info_dassert(0 != result, "Stop should succeed");
|
||||
|
||||
ss_info_dassert(success, "Session allocation failed");
|
||||
dcb = dcb_alloc(DCB_ROLE_REQUEST_HANDLER);
|
||||
ss_info_dassert(dcb != NULL, "DCB allocation failed");
|
||||
|
||||
session = session_alloc(service,dcb);
|
||||
ss_info_dassert(session != NULL, "Session allocation failed");
|
||||
session->client->state = DCB_STATE_POLLING;
|
||||
session->client->func.hangup = hup;
|
||||
sleep(15);
|
||||
|
||||
ss_info_dassert(success, "Session timeout failed");
|
||||
|
||||
ss_dfprintf(stderr, "\t..done\nStopping Service.");
|
||||
ss_info_dassert(0 != serviceStop(service), "Stop should succeed");
|
||||
ss_dfprintf(stderr, "\t..done\n");
|
||||
ss_dfprintf(stderr, "\t..done\n");
|
||||
|
||||
/** This is never used in MaxScale and will always fail due to service's
|
||||
* stats.n_current value never being decremented */
|
||||
/*
|
||||
|
11
server/include/hk_heartbeat.h
Normal file
11
server/include/hk_heartbeat.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef _HK_HEARTBEAT_H
|
||||
#define _HK_HEARTBEAT_H
|
||||
|
||||
/**
|
||||
* The global housekeeper heartbeat value. This value is increamente
|
||||
* every 100ms and may be used for crude timing etc.
|
||||
*/
|
||||
|
||||
extern unsigned long hkheartbeat;
|
||||
|
||||
#endif
|
@ -19,7 +19,7 @@
|
||||
*/
|
||||
#include <time.h>
|
||||
#include <dcb.h>
|
||||
|
||||
#include <hk_heartbeat.h>
|
||||
/**
|
||||
* @file housekeeper.h A mechanism to have task run periodically
|
||||
*
|
||||
@ -52,12 +52,6 @@ typedef struct hktask {
|
||||
*next; /*< Next task in the list */
|
||||
} HKTASK;
|
||||
|
||||
/**
|
||||
* The global housekeeper heartbeat value. This value is increamente
|
||||
* every 100ms and may be used for crude timing etc.
|
||||
*/
|
||||
extern unsigned long hkheartbeat;
|
||||
|
||||
extern void hkinit();
|
||||
extern int hktask_add(char *name, void (*task)(void *), void *data, int frequency);
|
||||
extern int hktask_oneshot(char *name, void (*task)(void *), void *data, int when);
|
||||
|
@ -145,8 +145,6 @@ char *password;
|
||||
if ((n = dcb_read(dcb, &head)) != -1)
|
||||
{
|
||||
|
||||
dcb->last_read = hkheartbeat;
|
||||
|
||||
if (head)
|
||||
{
|
||||
unsigned char *ptr = GWBUF_DATA(head);
|
||||
|
@ -448,8 +448,6 @@ static int gw_read_backend_event(DCB *dcb) {
|
||||
/* read available backend data */
|
||||
rc = dcb_read(dcb, &read_buffer);
|
||||
|
||||
dcb->last_read = hkheartbeat;
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
GWBUF* errbuf;
|
||||
|
@ -576,7 +576,6 @@ int gw_read_client_event(
|
||||
CHK_PROTOCOL(protocol);
|
||||
rc = dcb_read(dcb, &read_buffer);
|
||||
|
||||
dcb->last_read = hkheartbeat;
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
|
@ -157,8 +157,6 @@ char *password, *t;
|
||||
if ((n = dcb_read(dcb, &head)) != -1)
|
||||
{
|
||||
|
||||
dcb->last_read = hkheartbeat;
|
||||
|
||||
if (head)
|
||||
{
|
||||
unsigned char *ptr = GWBUF_DATA(head);
|
||||
|
Reference in New Issue
Block a user