nftlock

package
v1.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const LockPath = "/run/nftban/nft_operations.lock"

LockPath is the canonical lock file for all nft operations. Both Go (syscall.Flock) and shell (flock(1)) use this same file.

Variables

View Source
var ErrLockBusy = fmt.Errorf("nft lock busy")

ErrLockBusy is returned when a non-blocking lock attempt finds the lock held

View Source
var ErrLockTimeout = fmt.Errorf("nft lock timeout")

ErrLockTimeout is returned when lock acquisition times out

Functions

This section is empty.

Types

type Lock

type Lock struct {
	// contains filtered or unexported fields
}

Lock represents an acquired file lock

func AcquireExclusive

func AcquireExclusive(timeout time.Duration) (*Lock, error)

AcquireExclusive acquires an exclusive lock for nft write operations. Blocks until the lock is acquired or timeout expires. Use for: nft add element, nft delete element, nft flush set, reconciliation.

func AcquireShared

func AcquireShared(timeout time.Duration) (*Lock, error)

AcquireShared acquires a shared lock for nft read operations. Multiple shared locks can be held simultaneously. Use for: rare direct nft list set reads (not for cache file reads).

func TryAcquireExclusive

func TryAcquireExclusive() (*Lock, error)

TryAcquireExclusive tries to acquire an exclusive lock without blocking. Returns nil, ErrLockBusy if the lock is already held.

func (*Lock) Release

func (l *Lock) Release()

Release releases the lock

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL