[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?
- To: libevent-users@xxxxxxxxxxxxx
- Subject: [Libevent-users] Does EV_PERSIST with a timeout work differently on 1.x and 2.x versions?
- From: Clint Webb <webb.clint@xxxxxxxxx>
- Date: Mon, 6 Dec 2010 10:13:14 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Sun, 05 Dec 2010 21:13:44 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:from:date :message-id:subject:to:content-type; bh=IwDXa7af5WKwURafi+xvF3IJ2wd9RfA4spF/5esm9/4=; b=Ay+lf+jXeERFPnRfKdp5/HBUZ3FZLLkj8eneNJmg8b0++UPDu9Ywm6i2uUeSPR5DrF AbNrVkr5RY9sK5C8RCNcAmzWEJFFWDtPMQ+MNKdVtddws0xbHV7d5QhghEtuPkp7dijG NQvNka3oa/zORjA3w+5T6UEFTRjB7GOzI5SUI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=x6C1bT9WlWvi1Y2pG2NaMrppk8mYjev9tP4RKyGUEkjQ2PL6iQXbJZP+mQMDs3QBBT BW3W4jhA2DI0J4HMYwZiLtq3cMZzMYyx3TAF9c7At5WD8fTUJ3g7HksHg5nIirFOVYX9 nK9jEYfRODbSSru9M6EYH3ES6KrcyMma+2Cog=
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
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.