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 <skygw_utils.h>
|
||||||
#include <log_manager.h>
|
#include <log_manager.h>
|
||||||
#include <hashtable.h>
|
#include <hashtable.h>
|
||||||
|
#include <hk_heartbeat.h>
|
||||||
|
|
||||||
/** Defined in log_manager.cc */
|
/** Defined in log_manager.cc */
|
||||||
extern int lm_enabled_logfiles_bitmask;
|
extern int lm_enabled_logfiles_bitmask;
|
||||||
@ -816,6 +817,9 @@ int dcb_read(
|
|||||||
n = 0;
|
n = 0;
|
||||||
goto return_n;
|
goto return_n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dcb->last_read = hkheartbeat;
|
||||||
|
|
||||||
bufsize = MIN(b, MAX_BUFFER_SIZE);
|
bufsize = MIN(b, MAX_BUFFER_SIZE);
|
||||||
|
|
||||||
if ((buffer = gwbuf_alloc(bufsize)) == NULL)
|
if ((buffer = gwbuf_alloc(bufsize)) == NULL)
|
||||||
|
@ -98,22 +98,31 @@ hkinit();
|
|||||||
skygw_log_sync_all();
|
skygw_log_sync_all();
|
||||||
ss_info_dassert(0 != result, "Start all should succeed");
|
ss_info_dassert(0 != result, "Start all should succeed");
|
||||||
|
|
||||||
ss_dfprintf(stderr, "\t..done\nTiming out a session.");
|
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");
|
|
||||||
|
|
||||||
session = session_alloc(service,dcb);
|
service->conn_timeout = 1;
|
||||||
ss_info_dassert(session != NULL, "Session allocation failed");
|
result = serviceStart(service);
|
||||||
session->client->state = DCB_STATE_POLLING;
|
skygw_log_sync_all();
|
||||||
session->client->func.hangup = hup;
|
ss_info_dassert(0 != result, "Start should succeed");
|
||||||
sleep(30);
|
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_dfprintf(stderr, "\t..done\nStopping Service.");
|
||||||
ss_info_dassert(0 != serviceStop(service), "Stop should succeed");
|
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
|
/** This is never used in MaxScale and will always fail due to service's
|
||||||
* stats.n_current value never being decremented */
|
* 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 <time.h>
|
||||||
#include <dcb.h>
|
#include <dcb.h>
|
||||||
|
#include <hk_heartbeat.h>
|
||||||
/**
|
/**
|
||||||
* @file housekeeper.h A mechanism to have task run periodically
|
* @file housekeeper.h A mechanism to have task run periodically
|
||||||
*
|
*
|
||||||
@ -52,12 +52,6 @@ typedef struct hktask {
|
|||||||
*next; /*< Next task in the list */
|
*next; /*< Next task in the list */
|
||||||
} HKTASK;
|
} 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 void hkinit();
|
||||||
extern int hktask_add(char *name, void (*task)(void *), void *data, int frequency);
|
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);
|
extern int hktask_oneshot(char *name, void (*task)(void *), void *data, int when);
|
||||||
|
@ -144,9 +144,7 @@ char *password;
|
|||||||
|
|
||||||
if ((n = dcb_read(dcb, &head)) != -1)
|
if ((n = dcb_read(dcb, &head)) != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
dcb->last_read = hkheartbeat;
|
|
||||||
|
|
||||||
if (head)
|
if (head)
|
||||||
{
|
{
|
||||||
unsigned char *ptr = GWBUF_DATA(head);
|
unsigned char *ptr = GWBUF_DATA(head);
|
||||||
|
@ -447,9 +447,7 @@ static int gw_read_backend_event(DCB *dcb) {
|
|||||||
|
|
||||||
/* read available backend data */
|
/* read available backend data */
|
||||||
rc = dcb_read(dcb, &read_buffer);
|
rc = dcb_read(dcb, &read_buffer);
|
||||||
|
|
||||||
dcb->last_read = hkheartbeat;
|
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
GWBUF* errbuf;
|
GWBUF* errbuf;
|
||||||
|
@ -576,7 +576,6 @@ int gw_read_client_event(
|
|||||||
CHK_PROTOCOL(protocol);
|
CHK_PROTOCOL(protocol);
|
||||||
rc = dcb_read(dcb, &read_buffer);
|
rc = dcb_read(dcb, &read_buffer);
|
||||||
|
|
||||||
dcb->last_read = hkheartbeat;
|
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
{
|
{
|
||||||
|
@ -156,9 +156,7 @@ char *password, *t;
|
|||||||
|
|
||||||
if ((n = dcb_read(dcb, &head)) != -1)
|
if ((n = dcb_read(dcb, &head)) != -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
dcb->last_read = hkheartbeat;
|
|
||||||
|
|
||||||
if (head)
|
if (head)
|
||||||
{
|
{
|
||||||
unsigned char *ptr = GWBUF_DATA(head);
|
unsigned char *ptr = GWBUF_DATA(head);
|
||||||
|
Reference in New Issue
Block a user