Commit Graph

11 Commits

Author SHA1 Message Date
Miloslav Trmač eeadee46d6 Fix races in lockfile_test.go
go { cmd.Run() } means the cmd will be destructed,
and stdin/stdout/stderr closed, concurrently with
other goroutines trying to access stdin/stdout/stderr.

Instead, do it the more traditional way and let the callers
who create those subprocesses explicitly manage their lifetime.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:54 +02:00
Miloslav Trmač 2d90000b09 Add missing error checks in tests
... and remove one WriteFile that was always failing.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-14 17:17:54 +02:00
Miloslav Trmač 082a8161ed Remove lockfile.Locker.RecursiveLock
It is not valid as currently implemented, and there is no known user.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-07 19:45:14 +02:00
Miloslav Trmač f42467020f Misc. warning cleanups
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-10-01 02:53:06 +02:00
Miloslav Trmač a1ccc9d862 Use os.WriteFile instead of ioutil.WriteFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:31:34 +02:00
Miloslav Trmač cfbc77122a Use os.CreateTemp instead of ioutil.TempFile
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2022-09-12 16:30:48 +02:00
Daniel J Walsh 534b0b3281
Standardize on capatalized logrus messages, and remove stutters
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-23 14:43:35 -04:00
Nalin Dahyabhai 38df75ce9b TestLockfileWriteConcurrent: stay below 8192 goroutines
The Go race detector will kill the test if it tries to have more than
8192 goroutines active at once, so start 8,000 instead of 100,000.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-03-22 14:39:40 -04:00
Nalin Dahyabhai 58be038c06 pkg/lockfile: fix a race and an incorrect unit test
Fix a race where the state lock in a Unixy lockfile structure wasn't
being used to protect access to all of the structure's state fields.

Fix usage of sync/atomic in the corresponding unit tests to not mix
atomic adds and reads with non-atomic reads, something which the race
detector complained about.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-02-22 18:24:04 -05:00
Sascha Grunert fd72b45a3f
Enable golint linter and fix lints
Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-01-28 15:59:15 +01:00
Nalin Dahyabhai 2dfeb3edf7 Move lockfiles to their own package
Move the lockfile implementation into a subpackage so that we can use it
in the devicemapper driver.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2019-07-02 11:14:04 -04:00