MXS-2067: Remove spinlock.h

Removed the spinlock.h header and replaced with plain pthread types and
functions.
This commit is contained in:
Markus Mäkelä
2018-09-26 18:55:10 +03:00
parent c95adf1f2e
commit 9278da1f54
50 changed files with 392 additions and 472 deletions

View File

@ -34,7 +34,6 @@
#include <maxscale/router.h>
#include <maxscale/modinfo.h>
#include <maxbase/atomic.h>
#include <maxscale/spinlock.h>
#include <maxscale/dcb.h>
#include <maxscale/alloc.h>
#include <maxscale/poll.h>
@ -53,7 +52,7 @@ static uint64_t getCapabilities(MXS_ROUTER* instance);
extern int execute_cmd(CLI_SESSION* cli);
static SPINLOCK instlock;
static pthread_mutex_t instlock;
static CLI_INSTANCE* instances;
/**
@ -67,7 +66,7 @@ static CLI_INSTANCE* instances;
extern "C" MXS_MODULE* MXS_CREATE_MODULE()
{
MXS_NOTICE("Initialise debug CLI router module.");
spinlock_init(&instlock);
pthread_mutex_init(&instlock, NULL);
instances = NULL;
static MXS_ROUTER_OBJECT MyObject =
@ -125,7 +124,7 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params
}
inst->service = service;
spinlock_init(&inst->lock);
pthread_mutex_init(&inst->lock, NULL);
inst->sessions = NULL;
/*
@ -133,10 +132,10 @@ static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params
* insert this router instance into the linked list of routers
* that have been created with this module.
*/
spinlock_acquire(&instlock);
pthread_mutex_lock(&instlock);
inst->next = instances;
instances = inst;
spinlock_release(&instlock);
pthread_mutex_unlock(&instlock);
return (MXS_ROUTER*)inst;
}
@ -161,10 +160,10 @@ static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session
memset(client->cmdbuf, 0, 80);
spinlock_acquire(&inst->lock);
pthread_mutex_lock(&inst->lock);
client->next = inst->sessions;
inst->sessions = client;
spinlock_release(&inst->lock);
pthread_mutex_unlock(&inst->lock);
session->state = SESSION_STATE_READY;
@ -187,7 +186,7 @@ static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_sessio
CLI_SESSION* session = (CLI_SESSION*)router_session;
spinlock_acquire(&inst->lock);
pthread_mutex_lock(&inst->lock);
if (inst->sessions == session)
{
inst->sessions = session->next;
@ -204,7 +203,7 @@ static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* router_sessio
ptr->next = session->next;
}
}
spinlock_release(&inst->lock);
pthread_mutex_unlock(&inst->lock);
/**
* Router session is freed in session.c:session_close, when session who
* owns it, is freed.

View File

@ -49,7 +49,6 @@
#include <maxscale/router.h>
#include <maxscale/server.hh>
#include <maxscale/service.h>
#include <maxscale/spinlock.h>
#include <maxscale/users.h>
#include <maxscale/utils.h>
#include <maxscale/version.h>
@ -1232,7 +1231,7 @@ struct subcommand flushoptions[] =
};
/** This is used to prevent concurrent creation or removal of servers */
static SPINLOCK server_mod_lock = SPINLOCK_INIT;
static pthread_mutex_t server_mod_lock = PTHREAD_MUTEX_INITIALIZER;
/**
* Create a new server
@ -1251,7 +1250,7 @@ static void createServer(DCB* dcb,
char* protocol,
char* authenticator)
{
spinlock_acquire(&server_mod_lock);
pthread_mutex_lock(&server_mod_lock);
if (server_find_by_unique_name(name) == NULL)
{
@ -1269,7 +1268,7 @@ static void createServer(DCB* dcb,
dcb_printf(dcb, "Server '%s' already exists.\n", name);
}
spinlock_release(&server_mod_lock);
pthread_mutex_unlock(&server_mod_lock);
}
static void createListener(DCB* dcb,
@ -2082,7 +2081,7 @@ static bool user_is_authorized(DCB* dcb)
return rval;
}
static SPINLOCK debugcmd_lock = SPINLOCK_INIT;
static pthread_mutex_t debugcmd_lock = PTHREAD_MUTEX_INITIALIZER;
static const char item_separator[] =
"----------------------------------------------------------------------------\n";
@ -2177,7 +2176,7 @@ int execute_cmd(CLI_SESSION* cli)
argc = i - 2; /* The number of extra arguments to commands */
spinlock_acquire(&debugcmd_lock);
pthread_mutex_lock(&debugcmd_lock);
if (!strcasecmp(args[0], "help"))
{
@ -2504,7 +2503,7 @@ int execute_cmd(CLI_SESSION* cli)
args[0]);
}
spinlock_release(&debugcmd_lock);
pthread_mutex_unlock(&debugcmd_lock);
memset(cli->cmdbuf, 0, CMDBUFLEN);