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

[Libevent-users] Does EV_PERSIST with a timeout work differently on 1.x and 2.x versions?



I've got a number of network apps I've recently had to retrofit so
that they work with libevent 1.x.  They were originally written for
libevent 2.x and worked well.

But since we had to run the apps on some machines that would not
likely have the 2.x libraries, I've made it so that the code should
work on both.

I ran across an interesting problem which confused me for a while.

Once a socket is established, I was setting a READ event with
EV_PERSIST.  When adding to the event-queue, I also added a 5 second
timeout.   In 2.x this worked fine, with the 5 second timeout
happening regularly and as expected, if no data was coming though the
socket.

With mostly the same code, 1.x was not working.  We were getting the
initial data, but after that, were not getting the events.  After
searching almost everything else first, I wondered if the timeout had
anything to do with it, and sure enough, it did.

After the Timeout event was fired, it seemed as though the event was
no longer queued, even though EV_PERSIST was specified.

Is this different behaviour expected?

To fix this, I removed the EV_PERSIST, and merely added the event at
the end of the callback, which is working fine.  Personally I like the
way that 2.x does it, but it really doesn't matter as the way I have
it now works as well.

Just thought I'd put it out there.

-- 
"Be excellent to each other"
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.