Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
a35bc53b
Commit
a35bc53b
authored
Jul 30, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3f3c556c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
11 deletions
+18
-11
go/zodb/connection.go
go/zodb/connection.go
+10
-6
go/zodb/db.go
go/zodb/db.go
+8
-5
No files found.
go/zodb/connection.go
View file @
a35bc53b
...
...
@@ -176,7 +176,7 @@ func (conn *Connection) get(class string, oid Oid) (IPersistent, error) {
// The object's data is not necessarily loaded after Get returns. Use
// PActivate to make sure the object is fully loaded.
func
(
conn
*
Connection
)
Get
(
ctx
context
.
Context
,
oid
Oid
)
(
IPersistent
,
error
)
{
conn
.
checkTxn
(
ctx
,
"Get"
)
conn
.
checkTxn
Ctx
(
ctx
,
"Get"
)
conn
.
objmu
.
Lock
()
// XXX -> rlock
wobj
:=
conn
.
objtab
[
oid
]
...
...
@@ -215,7 +215,7 @@ func (conn *Connection) Get(ctx context.Context, oid Oid) (IPersistent, error) {
// load loads object specified by oid.
func
(
conn
*
Connection
)
load
(
ctx
context
.
Context
,
oid
Oid
)
(
_
*
mem
.
Buf
,
serial
Tid
,
_
error
)
{
conn
.
checkTxn
(
ctx
,
"load"
)
conn
.
checkTxn
Ctx
(
ctx
,
"load"
)
return
conn
.
stor
.
Load
(
ctx
,
Xid
{
Oid
:
oid
,
At
:
conn
.
at
})
}
...
...
@@ -223,10 +223,14 @@ func (conn *Connection) load(ctx context.Context, oid Oid) (_ *mem.Buf, serial T
// ----------------------------------------
// checkTxn asserts that current transaction is the same as conn.txn .
func
(
conn
*
Connection
)
checkTxn
(
ctx
context
.
Context
,
who
string
)
{
if
txn
:=
transaction
.
Current
(
ctx
);
txn
!=
conn
.
txn
{
// checkTxnCtx asserts that current transaction is the same as conn.txn .
func
(
conn
*
Connection
)
checkTxnCtx
(
ctx
context
.
Context
,
who
string
)
{
conn
.
checkTxn
(
transaction
.
Current
(
ctx
),
who
)
}
// checkTxn asserts that specified "current" transaction is the same as conn.txn .
func
(
conn
*
Connection
)
checkTxn
(
txn
transaction
.
Transaction
,
who
string
)
{
if
txn
!=
conn
.
txn
{
panic
(
"connection: "
+
who
+
"current transaction is different from connection transaction"
)
}
}
go/zodb/db.go
View file @
a35bc53b
...
...
@@ -109,13 +109,16 @@ func (db *DB) put(conn *Connection) {
type
connTxnSync
Connection
// hide from public API
func
(
conn
*
connTxnSync
)
BeforeCompletion
(
txn
transaction
.
Transaction
)
{
// XXX check txn
func
(
csync
*
connTxnSync
)
BeforeCompletion
(
txn
transaction
.
Transaction
)
{
conn
:=
(
*
Connection
)(
csync
)
conn
.
checkTxn
(
txn
,
"BeforeCompletion"
)
// nothing
}
func
(
conn
*
connTxnSync
)
AfterCompletion
(
txn
transaction
.
Transaction
)
{
// XXX check txn
func
(
csync
*
connTxnSync
)
AfterCompletion
(
txn
transaction
.
Transaction
)
{
conn
:=
(
*
Connection
)(
csync
)
conn
.
checkTxn
(
txn
,
"AfterCompletion"
)
conn
.
db
.
put
((
*
Connection
)(
conn
))
// put conn back into db pool.
conn
.
db
.
put
(
conn
)
}
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