Changeset 3145

Show
Ignore:
Timestamp:
05/21/08 16:40:27 (6 months ago)
Author:
hans
Message:

Lock make-object transaction earlier to ensure read consistency.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/bos/bknr/src/data/object.lisp

    r2373 r3145  
    579579        (destroy-object obj))))) 
    580580 
     581;;; In order to avoid concurrency problems, we lock creation of 
     582;;; objects early.  Otherwise, we may run into the situation that an 
     583;;; object id is used for two objects. 
     584 
     585(defvar *make-object-lock* (mp-make-lock)) 
     586 
    581587(defun make-object (class-name &rest initargs) 
    582588  "Make a persistent object of class named CLASS-NAME. Calls MAKE-INSTANCE with INITARGS." 
    583   (execute (make-instance 'transaction 
    584                           :function-symbol 'tx-make-object 
    585                           :args (append (list class-name 
    586                                               :id (id-counter (store-object-subsystem))) 
    587                                         initargs)))) 
     589  (mp-with-recursive-lock-held (*make-object-lock*) 
     590    (execute (make-instance 'transaction 
     591                            :function-symbol 'tx-make-object 
     592                            :args (append (list class-name 
     593                                                :id (next-object-id (store-object-subsystem))) 
     594                                          initargs))))) 
    588595 
    589596(defun tx-delete-object (id)