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
8693a253
Commit
8693a253
authored
Jan 28, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a58e4c16
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
12 deletions
+13
-12
go/zodb/db.go
go/zodb/db.go
+13
-12
No files found.
go/zodb/db.go
View file @
8693a253
...
...
@@ -260,6 +260,9 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
at
=
head
}
db
.
mu
.
Lock
()
defer
db
.
mu
.
Unlock
()
conn
,
err
:=
db
.
open
(
ctx
,
at
,
opt
.
NoPool
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -272,6 +275,8 @@ func (db *DB) Open(ctx context.Context, opt *ConnOptions) (_ *Connection, err er
//
// it returns either new connection, or connection from the pool.
// returned connection does not neccessarily have .at=at, and have to go through .resync().
//
// must be called with db.mu locked.
func
(
db
*
DB
)
open
(
ctx
context
.
Context
,
at
Tid
,
noPool
bool
)
(
*
Connection
,
error
)
{
// NoPool connection - create anew
if
noPool
{
...
...
@@ -280,10 +285,7 @@ func (db *DB) open(ctx context.Context, at Tid, noPool bool) (*Connection, error
return
conn
,
nil
}
db
.
mu
.
Lock
()
defer
db
.
mu
.
Unlock
()
retry
:
// each loop iteration starts with db.mu locked
retry
:
for
{
// check if we already have the exact match
conn
:=
db
.
get
(
at
,
at
)
...
...
@@ -318,11 +320,11 @@ retry: // each loop iteration starts with db.mu locked
select
{
case
<-
ctx
.
Done
()
:
// XXX db.mu unlocked twice
return
nil
,
ctx
.
Err
()
case
<-
δready
:
// ok - δtail.head went over at
// ok - δtail.head went over at; relock db and retry
db
.
mu
.
Lock
()
continue
retry
}
}
...
...
@@ -363,20 +365,19 @@ func (conn *Connection) Resync(txn transaction.Transaction, at Tid) {
panic
(
"Conn.Resync: resync to at=0 (auto-mode is valid only for DB.Open)"
)
}
conn
.
db
.
mu
.
Lock
()
defer
conn
.
db
.
mu
.
Unlock
()
conn
.
resync
(
txn
,
at
)
}
// resync serves Connection.resync and DB.Open .
//
// must be called with conn.db.mu locked.
func
(
conn
*
Connection
)
resync
(
txn
transaction
.
Transaction
,
at
Tid
)
{
// XXX conn.cache.Lock ? - yes (e.g. if user also checks it from outside, right?)
// XXX assert conn.txn == nil
// XXX lock in caller?
db
:=
conn
.
db
db
.
mu
.
Lock
()
defer
db
.
mu
.
Unlock
()
δtail
:=
db
.
δtail
// XXX conn.at == at - do nothing (even if out of δtail coverave)
...
...
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