Permalink
Browse files

fix:[can't add a new key into hash during iteration] occurring in let…

…er then ruby 1.9.1 fixed.
  • Loading branch information...
1 parent 8fc72a1 commit f3027426cf783a0be1061b3903f870517ad9db1a @jun930 jun930 committed Apr 3, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 ruby/server/lib/roma/storage/rh_storage.rb
@@ -19,6 +19,30 @@ def opendb
}
end
+ if RUBY_VERSION >= '1.9.2'
+ def each_clean_up(t, vnhash)
+ @do_clean_up = true
+ nt = Time.now.to_i
+ @hdb.each{ |hdb|
+ keys = hdb.keys
+ keys.each{ |k|
+ v = hdb[k]
+ return unless @do_clean_up
+ vn, last, clk, expt = unpack_header(v)
+ vn_stat = vnhash[vn]
+ if vn_stat == :primary && ( (expt != 0 && nt > expt) || (expt == 0 && t > last) )
+ yield k, vn
+ hdb.out(k) if hdb.get(k) == v
+ elsif vn_stat == nil && t > last
+ yield k, vn
+ hdb.out(k) if hdb.get(k) == v
+ end
+ sleep @each_clean_up_sleep
+ }
+ }
+ end
+ end
+
private
def open_db(fname)

0 comments on commit f302742

Please sign in to comment.