1
0
Fork 0
mirror of https://github.com/Luzifer/streamdeck.git synced 2024-10-18 13:04:25 +00:00

Prevent system crash by too fast executions

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2021-02-26 23:16:40 +01:00
parent ecdf4967ae
commit a8ce516a64
Signed by: luzifer
GPG key ID: 0066F03ED215AD7D
2 changed files with 15 additions and 2 deletions

View file

@ -114,7 +114,14 @@ func (d displayElementExec) Display(ctx context.Context, idx int, attributes att
} }
func (d displayElementExec) NeedsLoop(attributes attributeCollection) bool { func (d displayElementExec) NeedsLoop(attributes attributeCollection) bool {
return attributes.Interval > 0 if attributes.Interval > 0 && attributes.Interval < 100*time.Millisecond {
log.WithFields(log.Fields{
"tpye": "exec",
"interval": attributes.Interval,
}).Warn("Ignoring interval below 100ms")
}
return attributes.Interval > 100*time.Millisecond
} }
func (d *displayElementExec) StartLoopDisplay(ctx context.Context, idx int, attributes attributeCollection) error { func (d *displayElementExec) StartLoopDisplay(ctx context.Context, idx int, attributes attributeCollection) error {

View file

@ -118,8 +118,14 @@ func (d displayElementPulseVolume) NeedsLoop(attributes attributeCollection) boo
func (d *displayElementPulseVolume) StartLoopDisplay(ctx context.Context, idx int, attributes attributeCollection) error { func (d *displayElementPulseVolume) StartLoopDisplay(ctx context.Context, idx int, attributes attributeCollection) error {
interval := time.Second interval := time.Second
if attributes.Interval > 0 { if attributes.Interval > 100*time.Millisecond {
interval = attributes.Interval interval = attributes.Interval
} else if attributes.Interval > 0 {
log.WithFields(log.Fields{
"tpye": "pulsevolume",
"idx": idx,
"interval": attributes.Interval,
}).Warn("Ignoring interval below 100ms")
} }
go func() { go func() {