Commit 39e27aa5 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f0931de9
......@@ -361,6 +361,13 @@ func (conn *Connection) get(pyclass pickle.Class, oid zodb.Oid) (PyObject, error
}
// load loads object specified by oid.
//
// XXX must be called ... (XXX e.g. outside transaction boundary) so that there is no race on .at .
func (conn *Connection) load(ctx context.Context, oid zodb.Oid) (_ *mem.Buf, serial zodb.Tid, _ error) {
return conn.stor.Load(ctx, zodb.Xid{Oid: oid, At: conn.at})
}
// loadpy loads object specified by oid and decodes it as a ZODB Python object.
//
// loadpy does not create any in-RAM object associated with Connection.
......@@ -499,7 +506,7 @@ func (obj *object) invalidate() {
// PActivate implements Object.
func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Lock()
ob.refcnt++
obj.refcnt++
doload := (obj.refcnt == 1 && obj.state == GHOST)
defer func() {
if err != nil {
......@@ -530,35 +537,33 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Unlock()
// do the loading outside of obj lock
buf, serial, err := obj.jar.load(ctx, obj.oid)
state, serial, err := obj.jar.load(ctx, obj.oid)
if err == nil {
err = obj.instance.SetState(buf) // XXX err ctx
buf.Release()
err = obj.instance.SetState(state) // XXX err ctx
state.Release()
}
// relock the object
pyobj.mu.Lock()
obj.mu.Lock()
// XXX assert pyobj.loading == loading
// XXX assert pyobj.state == GHOST
// XXX assert obj.loading == loading
// XXX assert obj.state == GHOST
pyobj.serial = serial
// pyobj.pystate = pystate
obj.serial = serial
if err == nil {
err = pyobj.instance.PySetState(pystate) // XXX err ctx
err = obj.instance.SetState(state) // XXX err ctx
state.Release()
}
if err != nil {
pyobj.instance.DropState() // XXX already in deactivate
obj.instance.DropState() // XXX already in deactivate
} else {
pyobj.state = UPTODATE
obj.state = UPTODATE
}
loading.err = err
pyobj.mu.Unlock()
obj.mu.Unlock()
close(loading.ready)
return err // XXX err ctx
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment