[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[Libevent-users] Event priorities



Hi folks

I'm working with priorities in events using libevent 2.0.13. Since I'm not using the most current release, I thought I'd ask about a behavior we are seeing that might be a potential bug.

I have attached a simple reproducer of the problem. In short, suppose I have setup 8 priorities for my event base. I then execute an event at priority 4. In that callback, I setup and activate two new events - first one at priority 4, and then another at priority 0. We then cycle back through the event loop.

Given the prioritized event base, I would expect the event at priority 0 to be called back first. However, this isn't what happens. Instead, the first event to be defined (in this case, the one at priority 4) is called back first.

Is this the expected behavior? Can someone point me to the error in this reproducer that might be causing the problem?

FWIW: I found that if I adjust the initial event's priority to something different than 4 (i.e., the level of the next event to be defined), then I get the expected behavior. So it appears that the problem is that when we return to the loop, we trigger any pending event of the same priority as the one we were in, instead of looping around to check the highest priority first.

Thanks
Ralph

Attachment: evpri-test2.c
Description: Binary data