/* * NOTE: The init callback should never be called multiple times, * let alone called from multiple threads. Therefore, locking * is unecessary here. */ int init (void) { int rc = SLURM_SUCCESS; /* * Need to dlopen() liblua.so with RTLD_GLOBAL in order to * ensure symbols from liblua are available to libs opened * by any lua scripts. */ if (!dlopen("liblua.so", RTLD_NOW | RTLD_GLOBAL) && !dlopen("liblua5.1.so", RTLD_NOW | RTLD_GLOBAL) && !dlopen("liblua5.1.so.0", RTLD_NOW | RTLD_GLOBAL)) { return (error("Failed to open liblua.so: %s", dlerror())); } /* * Initilize lua */ L = luaL_newstate (); luaL_openlibs (L); if (luaL_loadfile (L, lua_script_path)) return error ("lua: %s: %s", lua_script_path, lua_tostring (L, -1)); /* * Register slurm.log and slurm.error functions in lua state: */ lua_register_slurm_output_functions (); /* * Run the user script: */ if (lua_pcall (L, 0, 1, 0) != 0) return error ("proctrack/lua: %s: %s", lua_script_path, lua_tostring (L, -1)); /* * Get any return code from the lua script */ rc = (int) lua_tonumber (L, -1); lua_pop (L, 1); if (rc != SLURM_SUCCESS) return rc; /* * Check for required lua script functions: */ return (check_lua_script_functions ()); }
/* * NOTE: The init callback should never be called multiple times, * let alone called from multiple threads. Therefore, locking * is unecessary here. */ int init (void) { int rc = SLURM_SUCCESS; /* * Need to dlopen() the Lua library to ensure plugins see * appropriate symptoms */ if ((rc = xlua_dlopen()) != SLURM_SUCCESS) return rc; /* * Initilize lua */ L = luaL_newstate (); luaL_openlibs (L); if (luaL_loadfile (L, lua_script_path)) return error ("lua: %s: %s", lua_script_path, lua_tostring (L, -1)); /* * Register slurm.log and slurm.error functions in lua state: */ lua_register_slurm_output_functions (); /* * Run the user script: */ if (lua_pcall (L, 0, 1, 0) != 0) return error ("proctrack/lua: %s: %s", lua_script_path, lua_tostring (L, -1)); /* * Get any return code from the lua script */ rc = (int) lua_tonumber (L, -1); lua_pop (L, 1); if (rc != SLURM_SUCCESS) return rc; /* * Check for required lua script functions: */ return (check_lua_script_functions ()); }