mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
allow holder to close/open/close without panic on closing closed channel
This commit is contained in:
parent
396ec6e271
commit
69ef4a3746
2 changed files with 16 additions and 0 deletions
|
|
@ -101,6 +101,9 @@ func NewHolder() *Holder {
|
|||
|
||||
// Open initializes the root data directory for the holder.
|
||||
func (h *Holder) Open() error {
|
||||
// Reset closing in case Holder is being reopened.
|
||||
h.closing = make(chan struct{})
|
||||
|
||||
h.setFileLimit()
|
||||
|
||||
h.Logger.Printf("open holder path: %s", h.Path)
|
||||
|
|
@ -178,6 +181,9 @@ func (h *Holder) Close() error {
|
|||
}
|
||||
}
|
||||
|
||||
// Reset opened in case Holder needs to be reopened.
|
||||
h.opened = make(chan struct{})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,3 +287,13 @@ func TestHolderCleaner_CleanHolder(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure holder can reopen.
|
||||
func TestHolderCleaner_Reopen(t *testing.T) {
|
||||
h := NewHolder()
|
||||
h.Path = "path"
|
||||
h.Open()
|
||||
h.Close()
|
||||
h.Open()
|
||||
h.Close()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue