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 ...@@ -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 loads object specified by oid and decodes it as a ZODB Python object.
// //
// loadpy does not create any in-RAM object associated with Connection. // loadpy does not create any in-RAM object associated with Connection.
...@@ -499,7 +506,7 @@ func (obj *object) invalidate() { ...@@ -499,7 +506,7 @@ func (obj *object) invalidate() {
// PActivate implements Object. // PActivate implements Object.
func (obj *object) PActivate(ctx context.Context) (err error) { func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Lock() obj.mu.Lock()
ob.refcnt++ obj.refcnt++
doload := (obj.refcnt == 1 && obj.state == GHOST) doload := (obj.refcnt == 1 && obj.state == GHOST)
defer func() { defer func() {
if err != nil { if err != nil {
...@@ -530,35 +537,33 @@ func (obj *object) PActivate(ctx context.Context) (err error) { ...@@ -530,35 +537,33 @@ func (obj *object) PActivate(ctx context.Context) (err error) {
obj.mu.Unlock() obj.mu.Unlock()
// do the loading outside of obj lock // 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 { if err == nil {
err = obj.instance.SetState(buf) // XXX err ctx err = obj.instance.SetState(state) // XXX err ctx
buf.Release() state.Release()
} }
// relock the object // relock the object
pyobj.mu.Lock() obj.mu.Lock()
// XXX assert pyobj.loading == loading // XXX assert obj.loading == loading
// XXX assert pyobj.state == GHOST // XXX assert obj.state == GHOST
pyobj.serial = serial obj.serial = serial
// pyobj.pystate = pystate
if err == nil { if err == nil {
err = pyobj.instance.PySetState(pystate) // XXX err ctx err = obj.instance.SetState(state) // XXX err ctx
state.Release()
} }
if err != nil { if err != nil {
pyobj.instance.DropState() // XXX already in deactivate obj.instance.DropState() // XXX already in deactivate
} else { } else {
pyobj.state = UPTODATE obj.state = UPTODATE
} }
loading.err = err loading.err = err
pyobj.mu.Unlock() obj.mu.Unlock()
close(loading.ready) close(loading.ready)
return err // XXX err ctx 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