-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ndb: add read lock to prevent NDB blob magic error (#48)
This error can happen if the ndb packages file is being updated (e.g. zypper up) while we are reading it. The rpm binary uses a shared flock when running `rpm -qa` on the ndb backend. This commit does the same for go-rpmdb.
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//go:build linux || darwin | ||
|
||
package ndb | ||
|
||
import ( | ||
"syscall" | ||
) | ||
|
||
const ( | ||
syscallLOCK_SH = syscall.LOCK_SH | ||
syscallLOCK_UN = syscall.LOCK_UN | ||
) | ||
|
||
func syscallFlock(fd int, how int) error { | ||
return syscall.Flock(fd, how) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build windows | ||
|
||
package ndb | ||
|
||
const ( | ||
syscallLOCK_SH = 0 | ||
syscallLOCK_UN = 0 | ||
) | ||
|
||
func syscallFlock(fd int, how int) error { | ||
return nil | ||
} |