Remove references to QUEUE_CONFIG

Only used in conjunction with queued connections, which are not
enabled anyway. Once that comes on the table again, better to use
some standard data structures.
This commit is contained in:
Johan Wikman 2017-11-08 09:59:41 +02:00
parent e7342324d7
commit b1b78a5be7
4 changed files with 13 additions and 49 deletions

View File

@ -35,7 +35,6 @@
#include <maxscale/hashtable.h>
#include <maxscale/resultset.h>
#include <maxscale/config.h>
#include <maxscale/queuemanager.h>
#include <maxscale/jansson.h>
MXS_BEGIN_DECLS
@ -128,7 +127,6 @@ typedef struct service
int state; /**< The service state */
int client_count; /**< Number of connected clients */
int max_connections; /**< Maximum client connections */
QUEUE_CONFIG *queued_connections; /**< Queued connections, if set */
SERV_LISTENER *ports; /**< Linked list of ports and protocols
* that this service will listen on */
char *routerModule; /**< Name of router module to use */

View File

@ -596,7 +596,9 @@ bool runtime_alter_service(SERVICE *service, const char* zKey, const char* zValu
{
valid = true;
// TODO: Once connection queues are implemented, use correct values
serviceSetConnectionLimits(service, i, 0, 0);
const int queued_connections = 0; // At most this many pending connections.
const int timeout = 0; // Wait at most this much for a connection.
serviceSetConnectionLimits(service, i, queued_connections, timeout);
}
}
else if (key == CN_CONNECTION_TIMEOUT)

View File

@ -56,7 +56,6 @@
#include <maxscale/utils.h>
#include "maxscale/modules.h"
#include "maxscale/queuemanager.h"
#include "maxscale/semaphore.hh"
#include "maxscale/session.h"
#include "maxscale/worker.hh"
@ -2435,14 +2434,13 @@ dcb_accept(DCB *listener)
if (client_dcb->service->max_connections &&
client_dcb->service->client_count >= client_dcb->service->max_connections)
{
if (!mxs_enqueue(client_dcb->service->queued_connections, client_dcb))
// TODO: If connections can be queued, this is the place to put the
// TODO: connection on that queue.
if (client_dcb->func.connlimit)
{
if (client_dcb->func.connlimit)
{
client_dcb->func.connlimit(client_dcb, client_dcb->service->max_connections);
}
dcb_close(client_dcb);
client_dcb->func.connlimit(client_dcb, client_dcb->service->max_connections);
}
dcb_close(client_dcb);
client_dcb = NULL;
}
}

View File

@ -39,7 +39,6 @@
#include <maxscale/log_manager.h>
#include <maxscale/poll.h>
#include <maxscale/protocol.h>
#include <maxscale/queuemanager.h>
#include <maxscale/resultset.h>
#include <maxscale/router.h>
#include <maxscale/server.h>
@ -54,7 +53,6 @@
#include "maxscale/config.h"
#include "maxscale/filter.h"
#include "maxscale/modules.h"
#include "maxscale/queuemanager.h"
#include "maxscale/service.h"
/** This define is needed in CentOS 6 systems */
@ -97,7 +95,6 @@ static int find_type(typelib_t* tl, const char* needle, int maxlen);
static void service_add_qualified_param(SERVICE* svc,
MXS_CONFIG_PARAMETER* param);
static void service_internal_restart(void *data);
static void service_queue_check(void *data);
static void service_calculate_weights(SERVICE *service);
SERVICE* service_alloc(const char *name, const char *router)
@ -145,7 +142,6 @@ SERVICE* service_alloc(const char *name, const char *router)
service->name = my_name;
service->routerModule = my_router;
service->users_from_all = false;
service->queued_connections = NULL;
service->localhost_match_wildcard_host = SERVICE_PARAM_UNINIT;
service->retry_start = true;
service->conn_idle_timeout = SERVICE_NO_SESSION_TIMEOUT;
@ -1157,6 +1153,8 @@ void serviceSetVersionString(SERVICE *service, const char* value)
* @param max The maximum number of client connections at any one time
* @param queued The maximum number of connections to queue up when
* max_connections clients are already connected
* @param timeout Maximum amount of time to wait for a connection to
* become available.
* @return 1 on success, 0 when the values are invalid
*/
int
@ -1169,45 +1167,13 @@ serviceSetConnectionLimits(SERVICE *service, int max, int queued, int timeout)
}
service->max_connections = max;
if (queued && timeout)
{
char callback_name[100];
sprintf(callback_name, "Check queued connections %p", service);
/* If memory allocation fails, result will be null so no queue */
service->queued_connections = mxs_queue_alloc(queued, timeout);
if (service->queued_connections)
{
hktask_add(callback_name, service_queue_check, (void *)service->queued_connections, 1);
}
}
ss_info_dassert(queued == 0, "Queued connections not implemented.");
ss_info_dassert(timeout == 0, "Queued connections not implemented.");
return 1;
}
/*
* @brief The callback function triggered by housekeeping every second
*
* This function removes any expired connection requests from the queue, and
* sends an error message "too many connections" for them.
*
* @param The parameter provided by the callback is the queue config
*/
static void
service_queue_check(void *data)
{
QUEUE_ENTRY expired;
QUEUE_CONFIG *queue_config = (QUEUE_CONFIG *)data;
/* The queued connections are in a FIFO queue, so we only look at the */
/* start of the queue, and remove any expired entries. As soon as this */
/* returns nothing, we stop. */
while ((mxs_dequeue_if_expired(queue_config, &expired)))
{
DCB *dcb = (DCB *)expired.queued_object;
dcb->func.connlimit(dcb, queue_config->queue_limit);
dcb_close(dcb);
}
}
/**
* Enable or disable the restarting of the service on failure.
* @param service Service to configure