From 061542645c78dbe76f83a9e229b0cf4d59928495 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 24 Apr 2023 12:28:42 +0200 Subject: [PATCH 1/2] Fix test --- restream/restream_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restream/restream_test.go b/restream/restream_test.go index 208e30b0..c142c7fd 100644 --- a/restream/restream_test.go +++ b/restream/restream_test.go @@ -219,7 +219,7 @@ func TestUpdateProcess(t *testing.T) { process, err := rs.GetProcess(process2.ID) require.NoError(t, err) - //createdAt := process.CreatedAt + createdAt := process.CreatedAt updatedAt := process.UpdatedAt time.Sleep(2 * time.Second) @@ -241,7 +241,7 @@ func TestUpdateProcess(t *testing.T) { process, err = rs.GetProcess(process3.ID) require.NoError(t, err) - //require.Equal(t, createdAt, process.CreatedAt) + require.NotEqual(t, createdAt, process.CreatedAt) // this should be equal, but will require a major version jump require.NotEqual(t, updatedAt, process.UpdatedAt) } From b58cc8a7ee9fab3fd407fcdf477a52b8a3496062 Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Mon, 24 Apr 2023 16:09:01 +0200 Subject: [PATCH 2/2] Fix race condition --- process/process.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/process/process.go b/process/process.go index 4bfcb4b4..d1754822 100644 --- a/process/process.go +++ b/process/process.go @@ -593,6 +593,10 @@ func (p *process) stop(wait bool) error { if p.callbacks.onExit == nil { p.callbacks.onExit = func() { wg.Done() + + p.callbacks.lock.Lock() + defer p.callbacks.lock.Unlock() + p.callbacks.onExit = nil } } else { @@ -600,6 +604,10 @@ func (p *process) stop(wait bool) error { p.callbacks.onExit = func() { cb() wg.Done() + + p.callbacks.lock.Lock() + defer p.callbacks.lock.Unlock() + p.callbacks.onExit = cb } }