[blam] Do use an internal object for locking in Item



commit ab3e84f4bf518ee6fcea766fb50ef2bda43c8ad8
Author: Carlos MartÃn Nieto <carlos cmartin tk>
Date:   Wed Aug 24 16:12:34 2011 +0200

    Do use an internal object for locking in Item
    
    Locking on the 'this' object can lead to deadlocks. Use an internal
    object for locking.
    
    Thanks to AndrÃs G. Aragoneses for pointing this out.

 src/Item.cs |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/src/Item.cs b/src/Item.cs
index 0193535..8d201cf 100644
--- a/src/Item.cs
+++ b/src/Item.cs
@@ -18,6 +18,7 @@ namespace Imendio.Blam {
 		public string   keywords = "";
 
         private int ref_cnt = 0;
+        private Object ilock = new Object();
 
         public delegate void UpdateHandler(Item item);
         public event UpdateHandler Updated;
@@ -116,14 +117,14 @@ namespace Imendio.Blam {
 
         public Item(SyndicationItem item) : base(item)
         {
-            lock(this){
+            lock(ilock){
                 FillItem(item);
             }
         }
 
         public bool Update(SyndicationItem item)
         {
-            lock(this){
+            lock(ilock){
                 FillItem(item);
             }
             return true;



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