/** 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;
* and return the instance specific interpreter.
*/
if (!inst->threads) {
- pthread_mutex_lock(&inst->mutex);
+ pthread_mutex_lock(inst->mutex);
return inst->interpreter;
}
}
#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;
#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.
* 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)
}
#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;
}
#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;\