]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Set direct sqlite storage conn to nil on close
authorMatt Joiner <anacrolix@gmail.com>
Wed, 18 Aug 2021 06:56:05 +0000 (16:56 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 19 Aug 2021 03:37:00 +0000 (13:37 +1000)
This might help catch the reason for SQLITE_MISUSE in getCapacity.

storage/sqlite/direct.go

index 899cf1af3dd2646f46152c68b048e1a940650594..5e6b52ddb23d85600ec3879742b7914ce76b9f83 100644 (file)
@@ -114,15 +114,19 @@ func (c *client) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (stora
        return storage.TorrentImpl{Piece: t.Piece, Close: t.Close, Capacity: &c.capacity}, nil
 }
 
-func (c *client) Close() error {
+func (c *client) Close() (err error) {
        c.l.Lock()
        defer c.l.Unlock()
        c.flushBlobs()
-       c.closed = true
        if c.opts.BlobFlushInterval != 0 {
                c.blobFlusher.Stop()
        }
-       return c.conn.Close()
+       if !c.closed {
+               c.closed = true
+               err = c.conn.Close()
+               c.conn = nil
+       }
+       return
 }
 
 type torrent struct {