Good catch! I'll promote that. I think the original intention was to
minimize locking, but you are correct in observing that the corner
case of length = 1 can lead to errors.
Thanks,
Ian
On May 28, 2008, at 5:26 AM, Alex Mizrahi wrote:
obviously broken code:
(defun get-circularity-hash ()
"Get a clean hash for object serialization"
(declare (type fixnum *circularity-initial-hash-size*))
(if (= 0 (length *circularity-hash-queue*))
(make-hash-table :test 'eq :size *circularity-initial-hash-size*)
(ele-with-fast-lock (*serializer-fast-lock*)
(vector-pop *circularity-hash-queue*))))
concurrent call could happen between check and pop, thus
invalidating the
check.
(defun get-cicularity-hash ()
(or
(ele-with-fast-lock (*serializer-fast-lock*)
(and (plusp (length *circularity-hash-queue*))
(vector-pop *circularity-hash-queue*)))
(make-hash-table :test 'eq :size *circularity-initial-hash-
size*)))
_______________________________________________
elephant-devel site list
elephant-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/elephant-devel
_______________________________________________
elephant-devel site list
elephant-devel@common-lisp.net
http://common-lisp.net/mailman/listinfo/elephant-devel