Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
4dc558f1
Commit
4dc558f1
authored
Aug 08, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6826989c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
15 deletions
+8
-15
go/zodb/connection.go
go/zodb/connection.go
+8
-15
No files found.
go/zodb/connection.go
View file @
4dc558f1
...
@@ -145,10 +145,7 @@ func (e *wrongClassError) Error() string {
...
@@ -145,10 +145,7 @@ func (e *wrongClassError) Error() string {
// Use-case: in ZODB references are (pyclass, oid), so new ghost is created
// Use-case: in ZODB references are (pyclass, oid), so new ghost is created
// without further loading anything.
// without further loading anything.
func
(
conn
*
Connection
)
get
(
class
string
,
oid
Oid
)
(
IPersistent
,
error
)
{
func
(
conn
*
Connection
)
get
(
class
string
,
oid
Oid
)
(
IPersistent
,
error
)
{
// XXX txn check
conn
.
objmu
.
Lock
()
// XXX -> rlock?
//conn.checkTxn("get")
conn
.
objmu
.
Lock
()
// XXX -> rlock
wobj
:=
conn
.
objtab
[
oid
]
wobj
:=
conn
.
objtab
[
oid
]
var
obj
IPersistent
var
obj
IPersistent
checkClass
:=
false
checkClass
:=
false
...
@@ -167,12 +164,9 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
...
@@ -167,12 +164,9 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
if
checkClass
{
if
checkClass
{
if
cls
:=
zclassOf
(
obj
);
class
!=
cls
{
if
cls
:=
zclassOf
(
obj
);
class
!=
cls
{
return
nil
,
&
OpError
{
var
err
error
=
&
wrongClassError
{
class
,
cls
}
URL
:
conn
.
stor
.
URL
(),
xerr
.
Contextf
(
&
err
,
"get %s"
,
Xid
{
conn
.
at
,
oid
})
Op
:
fmt
.
Sprintf
(
"@%s: get"
,
conn
.
at
),
// XXX abuse
return
nil
,
err
Args
:
oid
,
Err
:
&
wrongClassError
{
class
,
cls
},
}
}
}
}
}
...
@@ -193,7 +187,7 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (_ IPersistent, err er
...
@@ -193,7 +187,7 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (_ IPersistent, err er
conn
.
checkTxnCtx
(
ctx
,
"Get"
)
conn
.
checkTxnCtx
(
ctx
,
"Get"
)
defer
xerr
.
Contextf
(
&
err
,
"Get %s"
,
oid
)
defer
xerr
.
Contextf
(
&
err
,
"Get %s"
,
oid
)
conn
.
objmu
.
Lock
()
// XXX -> rlock
conn
.
objmu
.
Lock
()
// XXX -> rlock?
wobj
:=
conn
.
objtab
[
oid
]
wobj
:=
conn
.
objtab
[
oid
]
var
xobj
interface
{}
var
xobj
interface
{}
if
wobj
!=
nil
{
if
wobj
!=
nil
{
...
@@ -207,15 +201,16 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (_ IPersistent, err er
...
@@ -207,15 +201,16 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (_ IPersistent, err er
}
}
// object is not there in objtab - raw load it, get its class -> get(pyclass, oid)
// object is not there in objtab - raw load it, get its class -> get(pyclass, oid)
// XXX
py
hardcoded
// XXX
"py always"
hardcoded
class
,
pystate
,
serial
,
err
:=
conn
.
loadpy
(
ctx
,
oid
)
class
,
pystate
,
serial
,
err
:=
conn
.
loadpy
(
ctx
,
oid
)
if
err
!=
nil
{
if
err
!=
nil
{
xerr
.
Contextf
(
&
err
,
"Get %s"
,
Xid
{
conn
.
at
,
oid
})
return
nil
,
err
return
nil
,
err
}
}
obj
,
err
:=
conn
.
get
(
class
,
oid
)
obj
,
err
:=
conn
.
get
(
class
,
oid
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX double err ctx? (see get)
return
nil
,
err
}
}
// XXX we are dropping just loaded pystate. Usually Get should be used
// XXX we are dropping just loaded pystate. Usually Get should be used
...
@@ -239,8 +234,6 @@ func (conn *Connection) load(ctx context.Context, oid Oid) (_ *mem.Buf, serial T
...
@@ -239,8 +234,6 @@ func (conn *Connection) load(ctx context.Context, oid Oid) (_ *mem.Buf, serial T
// ----------------------------------------
// ----------------------------------------
// checkTxnCtx asserts that current transaction is the same as conn.txn .
// checkTxnCtx asserts that current transaction is the same as conn.txn .
//
// XXX swap naming?
func
(
conn
*
Connection
)
checkTxnCtx
(
ctx
context
.
Context
,
who
string
)
{
func
(
conn
*
Connection
)
checkTxnCtx
(
ctx
context
.
Context
,
who
string
)
{
conn
.
checkTxn
(
transaction
.
Current
(
ctx
),
who
)
conn
.
checkTxn
(
transaction
.
Current
(
ctx
),
who
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment