Skip to content

Commit cab7fd2

Browse files
committed
btcd: Fix nonzero exit code on sigint when indexing cfindex
1 parent 280d4d2 commit cab7fd2

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

blockchain/indexers/common.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ var (
2121
// fields for storage in the database.
2222
byteOrder = binary.LittleEndian
2323

24-
// errInterruptRequested indicates that an operation was cancelled due
24+
// ErrInterruptRequested indicates that an operation was cancelled due
2525
// to a user-requested interrupt.
26-
errInterruptRequested = errors.New("interrupt requested")
26+
ErrInterruptRequested = errors.New("interrupt requested")
2727
)
2828

2929
// NeedsInputser provides a generic interface for an indexer to specify the it

blockchain/indexers/manager.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func (m *Manager) maybeFinishDrops(interrupt <-chan struct{}) error {
176176
}
177177

178178
if interruptRequested(interrupt) {
179-
return errInterruptRequested
179+
return ErrInterruptRequested
180180
}
181181

182182
// Finish dropping any of the enabled indexes that are already in the
@@ -240,7 +240,7 @@ func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{})
240240
}
241241

242242
if interruptRequested(interrupt) {
243-
return errInterruptRequested
243+
return ErrInterruptRequested
244244
}
245245

246246
// Finish and drops that were previously interrupted.
@@ -350,7 +350,7 @@ func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{})
350350
}
351351

352352
if interruptRequested(interrupt) {
353-
return errInterruptRequested
353+
return ErrInterruptRequested
354354
}
355355
}
356356

@@ -411,7 +411,7 @@ func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{})
411411
}
412412

413413
if interruptRequested(interrupt) {
414-
return errInterruptRequested
414+
return ErrInterruptRequested
415415
}
416416

417417
// Connect the block for all indexes that need it.
@@ -448,7 +448,7 @@ func (m *Manager) Init(chain *blockchain.BlockChain, interrupt <-chan struct{})
448448
progressLogger.LogBlockHeight(block)
449449

450450
if interruptRequested(interrupt) {
451-
return errInterruptRequested
451+
return ErrInterruptRequested
452452
}
453453
}
454454

@@ -657,7 +657,7 @@ func dropIndex(db database.DB, idxKey []byte, idxName string, interrupt <-chan s
657657
}
658658

659659
if interruptRequested(interrupt) {
660-
return errInterruptRequested
660+
return ErrInterruptRequested
661661
}
662662

663663
// Drop the bucket itself.

btcd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ func btcdMain(serverChan chan<- *server) error {
265265
// Create server and start it.
266266
server, err := newServer(cfg.Listeners, cfg.AgentBlacklist,
267267
cfg.AgentWhitelist, db, activeNetParams.Params, interrupt)
268+
if err == indexers.ErrInterruptRequested {
269+
btcdLog.Infof("Unable to start server on %v: %v",
270+
cfg.Listeners, err)
271+
return nil
272+
}
268273
if err != nil {
269274
// TODO: this logging could do with some beautifying.
270275
btcdLog.Errorf("Unable to start server on %v: %v",

0 commit comments

Comments
 (0)