[grilo-plugins] lua-factory: Assert when overwriting user_data with concurrent resolves



commit 10d7ba8445296383f8e242ac0604e3680473d5ad
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Mar 17 16:52:09 2014 +0100

    lua-factory: Assert when overwriting user_data with concurrent resolves
    
    This will assert when multiple resolve calls are launched concurrently
    for the same lua source.
    
    We would set the operation spec for that state when calling resolve, but
    as it is asynchronous, the state would get assigned multiple operation
    specs, with the latter overwriting the earlier one.
    
    This is easily reproduced by browsing in grilo-test-ui and select
    different video items quickly, so one of the lua sources that implements
    resolve() gets called twice with the same lua state.
    
    The fix might be to have one lua state per call, or have a way to get
    the operation spec for that particular resolve call.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726563

 src/lua-factory/grl-lua-factory.c |    2 ++
 src/lua-factory/grl-lua-library.c |    3 +++
 2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/lua-factory/grl-lua-factory.c b/src/lua-factory/grl-lua-factory.c
index e0f84fe..aa51fd9 100644
--- a/src/lua-factory/grl-lua-factory.c
+++ b/src/lua-factory/grl-lua-factory.c
@@ -1076,6 +1076,8 @@ grl_lua_factory_source_resolve (GrlSource *source,
 
   GRL_DEBUG ("grl_lua_factory_source_resolve");
 
+  g_return_if_fail (grl_lua_library_load_operation_data (L) == NULL);
+
   os = g_slice_new0 (OperationSpec);
   os->source = rs->source;
   os->operation_id = rs->operation_id;
diff --git a/src/lua-factory/grl-lua-library.c b/src/lua-factory/grl-lua-library.c
index 5abf50e..936c512 100644
--- a/src/lua-factory/grl-lua-library.c
+++ b/src/lua-factory/grl-lua-library.c
@@ -693,6 +693,8 @@ grl_l_callback (lua_State *L)
 
   nparam = lua_gettop (L);
   os = grl_lua_library_load_operation_data (L);
+  g_return_val_if_fail (os != NULL, 0);
+
   media = (os->op_type == LUA_RESOLVE) ? os->media : NULL;
   if (nparam > 0) {
     media = grl_util_build_media (L, media);
@@ -714,6 +716,7 @@ grl_l_callback (lua_State *L)
     g_list_free (os->keys);
     g_object_unref (os->options);
     g_slice_free (OperationSpec, os);
+    grl_lua_library_save_operation_data (L, NULL);
   }
 
   return 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]