Commit 3d4b0d30 authored by alex@thinkpad's avatar alex@thinkpad
Browse files

Lua: refactored lua_take_semaphore calls

- checking for success: if (result == 0) instead of if(!result)
- checking whether "sem" was set: use assert (rather than giving the same error message as a semaphore timeout)

--HG--
branch : lua_fix
parent 7e8c58a8c76f
......@@ -163,8 +163,9 @@ static unsigned int lua_do_cbr(unsigned int ctx, struct script_event_entry * eve
if(current->function_ref != LUA_NOREF)
{
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, timeout, &sem) && sem)
if (lua_take_semaphore(L, timeout, &sem) == 0)
{
ASSERT(sem);
if(lua_rawgeti(L, LUA_REGISTRYINDEX, current->function_ref) == LUA_TFUNCTION)
{
lua_pushinteger(L, ctx);
......
......@@ -150,8 +150,9 @@ static LVINFO_UPDATE_FUNC(lua_lvinfo_update)
}
lua_State * L = entry->L;
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, 50, &sem) && sem)
if (lua_take_semaphore(L, 50, &sem) == 0)
{
ASSERT(sem);
if(entry->function_ref != LUA_NOREF)
{
if(lua_rawgeti(L, LUA_REGISTRYINDEX, entry->function_ref) == LUA_TFUNCTION)
......
......@@ -52,8 +52,9 @@ static MENU_SELECT_FUNC(script_menu_select)
{
lua_State * L = script_entry->L;
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, 500, &sem) && sem)
if (lua_take_semaphore(L, 500, &sem) == 0)
{
ASSERT(sem);
if(lua_rawgeti(L, LUA_REGISTRYINDEX, script_entry->select_ref) == LUA_TFUNCTION)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, script_entry->self_ref);
......@@ -85,8 +86,9 @@ static MENU_UPDATE_FUNC(script_menu_update)
{
lua_State * L = script_entry->L;
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, 100, &sem) && sem)
if (lua_take_semaphore(L, 100, &sem) == 0)
{
ASSERT(sem);
if (script_entry->menu_entry->children ||
script_entry->menu_entry->icon_type == IT_ACTION)
{
......
......@@ -68,8 +68,9 @@ static void lua_prop_task(int unused)
{
lua_State * L = lua_prop->L;
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, 1000, &sem) && sem)
if (lua_take_semaphore(L, 1000, &sem) == 0)
{
ASSERT(sem);
if(lua_rawgeti(L, LUA_REGISTRYINDEX, lua_prop->prop_handler_ref) == LUA_TFUNCTION)
{
lua_rawgeti(L, LUA_REGISTRYINDEX, lua_prop->self_ref);
......
......@@ -28,8 +28,9 @@ static void lua_run_task(struct lua_task_func * lua_task_func)
{
lua_State * L = lua_task_func->L;
struct semaphore * sem = NULL;
if(!lua_take_semaphore(L, 0, &sem) && sem)
if (lua_take_semaphore(L, 0, &sem) == 0)
{
ASSERT(sem);
if (lua_get_cant_yield(L) == -1)
{
/* main task was unloaded? continuing would be use after free */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment