File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,15 @@ const (
3939
4040type selinuxState struct {
4141 mcsList map [string ]bool
42+ cond * sync.Cond
4243 selinuxfs string
44+ maxMCSCount int
4345 selinuxfsOnce sync.Once
44- enabledSet bool
45- enabled bool
46+ mu sync.Mutex
4647 sync.Mutex
48+ enabledSet bool
49+ enabled bool
4750}
48-
4951type level struct {
5052 cats * big.Int
5153 sens int
@@ -936,6 +938,18 @@ func mcsAdd(mcs string) error {
936938 if mcs == "" {
937939 return nil
938940 }
941+ state .mu .Lock ()
942+ if state .maxMCSCount == 0 {
943+ state .maxMCSCount = int (CategoryRange * (CategoryRange - 1 ) / 2 )
944+ }
945+ if state .cond == nil {
946+ state .cond = sync .NewCond (& state .mu )
947+ }
948+ if len (state .mcsList ) >= state .maxMCSCount {
949+ state .cond .Wait ()
950+ }
951+ state .mu .Unlock ()
952+
939953 state .Lock ()
940954 defer state .Unlock ()
941955 if state .mcsList [mcs ] {
@@ -952,6 +966,9 @@ func mcsDelete(mcs string) {
952966 state .Lock ()
953967 defer state .Unlock ()
954968 state .mcsList [mcs ] = false
969+ state .mu .Lock ()
970+ state .cond .Signal ()
971+ state .mu .Unlock ()
955972}
956973
957974func intToMcs (id int , catRange uint32 ) string {
You can’t perform that action at this time.
0 commit comments