From a455cfb854ccee0407804ae2f8bda3814b42f893 Mon Sep 17 00:00:00 2001 From: lash Date: Sun, 22 Sep 2024 03:09:53 +0100 Subject: [PATCH 1/2] Return if duplicate connect --- internal/storage/gdbm.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/storage/gdbm.go b/internal/storage/gdbm.go index 5b6867c..7646159 100644 --- a/internal/storage/gdbm.go +++ b/internal/storage/gdbm.go @@ -30,6 +30,7 @@ func(tdb *ThreadGdbmDb) Connect(ctx context.Context, connStr string) error { _, ok = dbC[connStr] if ok { logg.WarnCtxf(ctx, "already registered thread gdbm, skipping", "connStr", connStr) + return nil } gdb := gdbmdb.NewGdbmDb() err := gdb.Connect(ctx, connStr) From 7d3ff690f0d12b9f9d6830c60726669d8c64eb20 Mon Sep 17 00:00:00 2001 From: lash Date: Sun, 22 Sep 2024 03:10:58 +0100 Subject: [PATCH 2/2] Remove useless 'registered' member in thread gdbm --- internal/storage/gdbm.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/internal/storage/gdbm.go b/internal/storage/gdbm.go index 7646159..eb959cf 100644 --- a/internal/storage/gdbm.go +++ b/internal/storage/gdbm.go @@ -14,7 +14,6 @@ var ( type ThreadGdbmDb struct { db db.Db - registered bool connStr string } @@ -40,7 +39,6 @@ func(tdb *ThreadGdbmDb) Connect(ctx context.Context, connStr string) error { dbC[connStr] = make(chan db.Db, 1) dbC[connStr]<- gdb tdb.connStr = connStr - tdb.registered = true return nil }