modify lock flow 93/45893/1
authorSooChan Lim <sc1.lim@samsung.com>
Wed, 12 Aug 2015 06:07:56 +0000 (15:07 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Wed, 12 Aug 2015 08:03:51 +0000 (17:03 +0900)
Change-Id: If9c06b4ba347f1d01ff22250b17a19adfbc03cb5

src/tbm_surface_internal.c

index 9f7e4e5..2041059 100755 (executable)
@@ -591,8 +591,10 @@ tbm_surface_internal_destroy (tbm_surface_h surface)
 
     surface->refcnt--;
 
-    if (surface->refcnt > 0)
+    if (surface->refcnt > 0) {
+        _tbm_surface_mutex_unlock();
         return;
+    }
 
     if (surface->refcnt == 0)
         _tbm_surface_internal_destroy(surface);
@@ -604,8 +606,6 @@ tbm_surface_internal_destroy (tbm_surface_h surface)
 void
 tbm_surface_internal_ref (tbm_surface_h surface)
 {
-    _tbm_surface_mutex_lock();
-
     TBM_RETURN_IF_FAIL (surface);
 
     _tbm_surface_mutex_lock();
@@ -618,14 +618,16 @@ tbm_surface_internal_ref (tbm_surface_h surface)
 void
 tbm_surface_internal_unref (tbm_surface_h surface)
 {
-    _tbm_surface_mutex_lock();
-
     TBM_RETURN_IF_FAIL (surface);
 
+    _tbm_surface_mutex_lock();
+
     surface->refcnt--;
 
-    if (surface->refcnt > 0)
+    if (surface->refcnt > 0) {
+        _tbm_surface_mutex_unlock();
         return;
+    }
 
     if (surface->refcnt == 0)
         _tbm_surface_internal_destroy(surface);