Commit b1aa6178 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 80b82f0a
...@@ -284,15 +284,16 @@ type hwaiter struct { ...@@ -284,15 +284,16 @@ type hwaiter struct {
// headWait waits till db.Head becomes ≥ at. // headWait waits till db.Head becomes ≥ at.
// //
// Must be called db.mu released. // It returns error either if db is down or ctx is canceled.
// //
// XXX -> waitHead? needHead? waitHeadAfter? ensureAt? // Must be called db.mu released.
func (db *DB) headWait(ctx context.Context, at Tid) (err error) { func (db *DB) headWait(ctx context.Context, at Tid) (err error) {
defer xerr.Contextf(&err, "wait head ≥ %s", at)
db.mu.Lock() db.mu.Lock()
// XXX check if db is already down -> error even if at is under coverage? // XXX check if db is already down -> error even if at is under coverage?
// XXX under mu - ok? // XXX under mu - ok?
// XXX err ctx
if ready(db.down) { if ready(db.down) {
return db.downErr return db.downErr
} }
...@@ -308,8 +309,6 @@ func (db *DB) headWait(ctx context.Context, at Tid) (err error) { ...@@ -308,8 +309,6 @@ func (db *DB) headWait(ctx context.Context, at Tid) (err error) {
db.hwait[hwaiter{at, δready}] = struct{}{} db.hwait[hwaiter{at, δready}] = struct{}{}
db.mu.Unlock() db.mu.Unlock()
defer xerr.Contextf(&err, "wait head ≥ %s", at)
select { select {
case <-δready: case <-δready:
// ok - δtail.head went over at // ok - δtail.head went over at
......
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