Improve performance, logging
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/Safing/portbase/log"
|
||||
@@ -11,13 +12,13 @@ var (
|
||||
activeProfileSetsLock sync.RWMutex
|
||||
)
|
||||
|
||||
func activateProfileSet(set *Set) {
|
||||
func activateProfileSet(ctx context.Context, set *Set) {
|
||||
activeProfileSetsLock.Lock()
|
||||
defer activeProfileSetsLock.Unlock()
|
||||
set.Lock()
|
||||
defer set.Unlock()
|
||||
activeProfileSets[set.id] = set
|
||||
log.Tracef("profile: activated profile set %s", set.id)
|
||||
log.Tracer(ctx).Tracef("profile: activated profile set %s", set.id)
|
||||
}
|
||||
|
||||
// DeactivateProfileSet marks a profile set as not active.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package profile
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
@@ -27,7 +28,7 @@ type Set struct {
|
||||
}
|
||||
|
||||
// NewSet returns a new profile set with given the profiles.
|
||||
func NewSet(id string, user, stamp *Profile) *Set {
|
||||
func NewSet(ctx context.Context, id string, user, stamp *Profile) *Set {
|
||||
new := &Set{
|
||||
id: id,
|
||||
profiles: [4]*Profile{
|
||||
@@ -37,7 +38,7 @@ func NewSet(id string, user, stamp *Profile) *Set {
|
||||
nil, // Default
|
||||
},
|
||||
}
|
||||
activateProfileSet(new)
|
||||
activateProfileSet(ctx, new)
|
||||
new.Update(status.SecurityLevelFortress)
|
||||
return new
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user