mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Fix race, can't clear direct memory since shared
Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
@@ -1134,9 +1134,11 @@ func (fs *fileStore) eraseMsg(mb *msgBlock, sm *fileStoredMsg) error {
|
||||
}
|
||||
// erase contents and rewrite with new hash.
|
||||
if len(sm.hdr) > 0 {
|
||||
sm.hdr = make([]byte, len(sm.hdr))
|
||||
rand.Read(sm.hdr)
|
||||
}
|
||||
if len(sm.msg) > 0 {
|
||||
sm.msg = make([]byte, len(sm.msg))
|
||||
rand.Read(sm.msg)
|
||||
}
|
||||
sm.seq, sm.ts = 0, 0
|
||||
|
||||
@@ -103,12 +103,6 @@ func TestFileStoreMsgHeaders(t *testing.T) {
|
||||
if removed, _ := fs.EraseMsg(1); !removed {
|
||||
t.Fatalf("Expected erase msg to return success")
|
||||
}
|
||||
if bytes.Equal(hdr, shdr) {
|
||||
t.Fatalf("Expected hdr to be erased")
|
||||
}
|
||||
if bytes.Equal(msg, smsg) {
|
||||
t.Fatalf("Expected msg to be erased")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFileStoreBasicWriteMsgsAndRestore(t *testing.T) {
|
||||
|
||||
@@ -323,12 +323,14 @@ func (ms *memStore) removeMsg(seq uint64, secure bool) bool {
|
||||
|
||||
if secure {
|
||||
if len(sm.hdr) > 0 {
|
||||
sm.hdr = make([]byte, len(sm.hdr))
|
||||
rand.Read(sm.hdr)
|
||||
}
|
||||
if len(sm.msg) > 0 {
|
||||
sm.msg = make([]byte, len(sm.msg))
|
||||
rand.Read(sm.msg)
|
||||
}
|
||||
sm.seq = 0
|
||||
sm.seq, sm.ts = 0, 0
|
||||
}
|
||||
|
||||
if ms.scb != nil {
|
||||
|
||||
@@ -215,9 +215,6 @@ func TestMemStoreEraseMsg(t *testing.T) {
|
||||
if removed, _ := ms.EraseMsg(1); !removed {
|
||||
t.Fatalf("Expected erase msg to return success")
|
||||
}
|
||||
if bytes.Equal(msg, smsg) {
|
||||
t.Fatalf("Expected msg to be erased")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMemStoreMsgHeaders(t *testing.T) {
|
||||
@@ -243,10 +240,4 @@ func TestMemStoreMsgHeaders(t *testing.T) {
|
||||
if removed, _ := ms.EraseMsg(1); !removed {
|
||||
t.Fatalf("Expected erase msg to return success")
|
||||
}
|
||||
if bytes.Equal(hdr, shdr) {
|
||||
t.Fatalf("Expected hdr to be erased")
|
||||
}
|
||||
if bytes.Equal(msg, smsg) {
|
||||
t.Fatalf("Expected msg to be erased")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user