Skip to content

Event API - timeout ignores filters #3714

@DragDen

Description

@DragDen

While spending a couple of days banging my head against the desk I noticed a rather suspicious part in an OpenOS event lib.
In the file /lib/event.lua on the lines 143-150 we have this code:

  repeat
    local signal = table.pack(computer.pullSignal(seconds))
    if signal.n > 0 then
      if not (seconds or filter) or filter == nil or filter(table.unpack(signal, 1, signal.n)) then
        return table.unpack(signal, 1, signal.n)
      end
    end
  until signal.n == 0

The 'seconds' variable here contains the amount of seconds for a timeout.
However, if I understand correctly, the timeout will only lapse if there is not a single event in computer's queue. Regardless of filters.

For example, if we're pulling for a modem_message with a timeout of two seconds, and repeatedly mash a key on the keyboard, the pullEvent will keep waiting indefinitely (until we leave the keyboard alone).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions