Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1152


Ignore:
Timestamp:
01/16/09 10:24:11 (16 years ago)
Author:
svonolfe
Message:

Fixed possible race condition in DAL (#372)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/CachedDataAdapter.cs

    r1149 r1152  
    105105    protected virtual ObjT FindSingle(Selector dbSelector,
    106106      Selector cacheSelector) {
     107      ObjT obj = default(ObjT);
     108
     109      cacheLock.AcquireReaderLock(Timeout.Infinite);
     110
    107111      RowT row = FindSingleRow(dbSelector, cacheSelector);
    108112
    109113      if (row != null) {
    110         ObjT obj = new ObjT();
     114        obj = new ObjT();
    111115        obj = Convert(row, obj);
    112        
    113         return obj;
    114       } else {
    115         return default(ObjT);
    116       }
     116      }
     117
     118      cacheLock.ReleaseReaderLock();
     119
     120      return obj;
    117121    }
    118122
     
    178182
    179183    protected override RowT GetRowById(long id) {
     184      cacheLock.AcquireReaderLock(Timeout.Infinite);
     185
    180186      RowT row =
    181187        FindCachedById(id);
    182188
     189      //not in cache
    183190      if (row == null)
    184191        row = FindSingleRow(
     
    186193            return FindById(id);
    187194          });
     195
     196      cacheLock.ReleaseReaderLock();
    188197
    189198      return row;
Note: See TracChangeset for help on using the changeset viewer.