Split queuemanager.h to public and core headers
Almost everything was moved to core.
This commit is contained in:
parent
8b83bf834e
commit
3b716bc707
@ -13,60 +13,14 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file queuemanager.h The Queue Manager header file
|
||||
*
|
||||
*
|
||||
* @verbatim
|
||||
* Revision History
|
||||
*
|
||||
* Date Who Description
|
||||
* 27/04/2016 Martin Brampton Initial implementation
|
||||
*
|
||||
* @endverbatim
|
||||
* @file queuemanager.h The Queue Manager public header
|
||||
*/
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <stdbool.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
#define CONNECTION_QUEUE_LIMIT 1000
|
||||
|
||||
typedef struct queue_entry
|
||||
{
|
||||
void *queued_object;
|
||||
long heartbeat;
|
||||
#if defined(SS_DEBUG)
|
||||
long sequence_check;
|
||||
#endif /* SS_DEBUG */
|
||||
} QUEUE_ENTRY;
|
||||
|
||||
typedef struct queue_config
|
||||
{
|
||||
int queue_limit;
|
||||
int start;
|
||||
int end;
|
||||
int timeout;
|
||||
bool has_entries;
|
||||
SPINLOCK queue_lock;
|
||||
QUEUE_ENTRY *queue_array;
|
||||
#if defined(SS_DEBUG)
|
||||
long sequence_number;
|
||||
#endif /* SS_DEBUG */
|
||||
} QUEUE_CONFIG;
|
||||
|
||||
QUEUE_CONFIG *mxs_queue_alloc(int limit, int timeout);
|
||||
void mxs_queue_free(QUEUE_CONFIG *queue_config);
|
||||
bool mxs_enqueue(QUEUE_CONFIG *queue_config, void *new_entry);
|
||||
bool mxs_dequeue(QUEUE_CONFIG *queue_config, QUEUE_ENTRY *result);
|
||||
bool mxs_dequeue_if_expired(QUEUE_CONFIG *queue_config, QUEUE_ENTRY *result);
|
||||
|
||||
static inline int
|
||||
mxs_queue_count(QUEUE_CONFIG *queue_config)
|
||||
{
|
||||
int count = queue_config->end - queue_config->start;
|
||||
return count < 0 ? (count + queue_config->queue_limit + 1) : count;
|
||||
}
|
||||
struct queue_config;
|
||||
typedef struct queue_config QUEUE_CONFIG;
|
||||
|
||||
MXS_END_DECLS
|
||||
|
@ -96,6 +96,7 @@
|
||||
|
||||
#include "maxscale/session.h"
|
||||
#include "maxscale/modules.h"
|
||||
#include "maxscale/queuemanager.h"
|
||||
|
||||
/* A DCB with null values, used for initialization */
|
||||
static DCB dcb_initialized = DCB_INIT;
|
||||
|
54
server/core/maxscale/queuemanager.h
Normal file
54
server/core/maxscale/queuemanager.h
Normal file
@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
/*
|
||||
* Copyright (c) 2016 MariaDB Corporation Ab
|
||||
*
|
||||
* Use of this software is governed by the Business Source License included
|
||||
* in the LICENSE.TXT file and at www.mariadb.com/bsl.
|
||||
*
|
||||
* Change Date: 2019-07-01
|
||||
*
|
||||
* On the date above, in accordance with the Business Source License, use
|
||||
* of this software will be governed by version 2 or later of the General
|
||||
* Public License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file core/maxscale/queuemanager.h - The private queuemanager interface
|
||||
*/
|
||||
|
||||
#include <maxscale/queuemanager.h>
|
||||
|
||||
#include <maxscale/spinlock.h>
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
typedef struct queue_entry
|
||||
{
|
||||
void *queued_object;
|
||||
long heartbeat;
|
||||
#if defined(SS_DEBUG)
|
||||
long sequence_check;
|
||||
#endif /* SS_DEBUG */
|
||||
} QUEUE_ENTRY;
|
||||
|
||||
typedef struct queue_config
|
||||
{
|
||||
int queue_limit;
|
||||
int start;
|
||||
int end;
|
||||
int timeout;
|
||||
bool has_entries;
|
||||
SPINLOCK queue_lock;
|
||||
QUEUE_ENTRY *queue_array;
|
||||
#if defined(SS_DEBUG)
|
||||
long sequence_number;
|
||||
#endif /* SS_DEBUG */
|
||||
} QUEUE_CONFIG;
|
||||
|
||||
QUEUE_CONFIG *mxs_queue_alloc(int limit, int timeout);
|
||||
void mxs_queue_free(QUEUE_CONFIG *queue_config);
|
||||
bool mxs_enqueue(QUEUE_CONFIG *queue_config, void *new_entry);
|
||||
bool mxs_dequeue(QUEUE_CONFIG *queue_config, QUEUE_ENTRY *result);
|
||||
bool mxs_dequeue_if_expired(QUEUE_CONFIG *queue_config, QUEUE_ENTRY *result);
|
||||
|
||||
MXS_END_DECLS
|
@ -25,20 +25,25 @@
|
||||
*
|
||||
* @endverbatim
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <maxscale/queuemanager.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <maxscale/alloc.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/hk_heartbeat.h>
|
||||
#include <maxscale/debug.h>
|
||||
#include <maxscale/hk_heartbeat.h>
|
||||
#include <maxscale/log_manager.h>
|
||||
#include <maxscale/spinlock.h>
|
||||
|
||||
#include "maxscale/queuemanager.h"
|
||||
|
||||
#if defined(SS_DEBUG)
|
||||
int debug_check_fail = 0;
|
||||
#endif /* SS_DEBUG */
|
||||
|
||||
static inline int mxs_queue_count(QUEUE_CONFIG*);
|
||||
|
||||
/**
|
||||
* @brief Allocate a new queue
|
||||
*
|
||||
@ -216,3 +221,9 @@ bool mxs_dequeue_if_expired(QUEUE_CONFIG *queue_config, QUEUE_ENTRY *result)
|
||||
}
|
||||
return (found != NULL);
|
||||
}
|
||||
|
||||
static inline int mxs_queue_count(QUEUE_CONFIG *queue_config)
|
||||
{
|
||||
int count = queue_config->end - queue_config->start;
|
||||
return count < 0 ? (count + queue_config->queue_limit + 1) : count;
|
||||
}
|
@ -68,8 +68,9 @@
|
||||
|
||||
#include "maxscale/config.h"
|
||||
#include "maxscale/filter.h"
|
||||
#include "maxscale/service.h"
|
||||
#include "maxscale/modules.h"
|
||||
#include "maxscale/queuemanager.h"
|
||||
#include "maxscale/service.h"
|
||||
|
||||
/** Base value for server weights */
|
||||
#define SERVICE_BASE_SERVER_WEIGHT 1000
|
||||
|
@ -37,11 +37,11 @@ extern int debug_check_fail;
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <maxscale/queuemanager.h>
|
||||
#include <maxscale/random_jkiss.h>
|
||||
#include <maxscale/hk_heartbeat.h>
|
||||
#include <maxscale/alloc.h>
|
||||
|
||||
#include "../maxscale/queuemanager.h"
|
||||
#include "test_utils.h"
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user