From: Alan T. DeKok Date: Mon, 14 Nov 2016 15:32:04 +0000 (-0500) Subject: const-ify it X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4eec929fe221b3b9d22c7dc12acb4ee223ab0cf8;p=thirdparty%2Ffreeradius-server.git const-ify it --- diff --git a/src/modules/rlm_lua/lua.c b/src/modules/rlm_lua/lua.c index c99f755cf9b..a30fb443c6b 100644 --- a/src/modules/rlm_lua/lua.c +++ b/src/modules/rlm_lua/lua.c @@ -720,7 +720,7 @@ static int _lua_state_free(lua_State **marker) /** Get a lua interpreter to use * */ -static lua_State *rlm_lua_get_interp(rlm_lua_t *inst) { +static lua_State *rlm_lua_get_interp(rlm_lua_t const *inst) { lua_State **marker; lua_State *L; @@ -730,7 +730,7 @@ static lua_State *rlm_lua_get_interp(rlm_lua_t *inst) { * and return the instance specific interpreter. */ if (!inst->threads) { - pthread_mutex_lock(&inst->mutex); + pthread_mutex_lock(inst->mutex); return inst->interpreter; } @@ -762,12 +762,12 @@ static lua_State *rlm_lua_get_interp(rlm_lua_t *inst) { } #ifdef HAVE_PTHREAD_H -#define rlm_lua_release_interp(_x) if (!_x->threads) pthread_mutex_unlock(&_x->mutex) +#define rlm_lua_release_interp(_x) if (!_x->threads) pthread_mutex_unlock(_x->mutex) #else #define rlm_lua_release_interp(_x) #endif -int do_lua(rlm_lua_t *inst, REQUEST *request, char const *funcname) +int do_lua(rlm_lua_t const *inst, REQUEST *request, char const *funcname) { vp_cursor_t cursor; lua_State *L; diff --git a/src/modules/rlm_lua/lua.h b/src/modules/rlm_lua/lua.h index b727d161a66..1108040cec9 100644 --- a/src/modules/rlm_lua/lua.h +++ b/src/modules/rlm_lua/lua.h @@ -52,7 +52,7 @@ typedef struct rlm_lua { #ifdef HAVE_PTHREAD_H pthread_key_t key; //!< Key to access the thread local and instance specific interpreter. - pthread_mutex_t mutex; //!< Mutex used to protect interpreter, when running with a single + pthread_mutex_t *mutex; //!< Mutex used to protect interpreter, when running with a single //!< interpreter (threads = no). #endif bool jit; //!< Whether the linked interpreter is Lua 5.1 or LuaJIT. diff --git a/src/modules/rlm_lua/rlm_lua.c b/src/modules/rlm_lua/rlm_lua.c index 673bd3213d3..63381286512 100644 --- a/src/modules/rlm_lua/rlm_lua.c +++ b/src/modules/rlm_lua/rlm_lua.c @@ -86,9 +86,9 @@ static void _tls_interp_destroy(void *ctx) * call lua_close and free the actual interpreter. */ rad_assert(inst = talloc_find_parent_bytype(marker, rlm_lua_t)); - pthread_mutex_lock(&inst->mutex); + pthread_mutex_lock(inst->mutex); talloc_free(marker); - pthread_mutex_unlock(&inst->mutex); + pthread_mutex_unlock(inst->mutex); } static int mod_instantiate(CONF_SECTION *conf, void *instance) @@ -101,7 +101,8 @@ static int mod_instantiate(CONF_SECTION *conf, void *instance) } #ifdef HAVE_PTHREAD_H - pthread_mutex_init(&inst->mutex, NULL); /* Used in both threaded and non-threaded modes */ + inst->mutex = talloc(inst, pthread_mutex_t); + pthread_mutex_init(inst->mutex, NULL); /* Used in both threaded and non-threaded modes */ if (inst->threads) { int errno; @@ -139,7 +140,7 @@ static int mod_detach(void *instance) } #define DO_LUA(_s)\ -static rlm_rcode_t mod_##_s(void const *instance, UNUSED void *thread, REQUEST *request) {\ +static rlm_rcode_t mod_##_s(void *instance, UNUSED void *thread, REQUEST *request) {\ rlm_lua_t const *inst = instance;\ if (!inst->func_##_s) {\ return RLM_MODULE_NOOP;\