[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] Bufferevent timeouts unclear.
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] Bufferevent timeouts unclear.
- From: Jj Jack <jjjack94@xxxxxxxxx>
- Date: Mon, 8 Feb 2010 11:12:07 -0800 (PST)
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Mon, 08 Feb 2010 14:12:14 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1265656327; bh=Yhj5vEAE3rH0+RfKxBqLplN9QoI1SqOCcWPTKW1cGvM=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=b6xyZfmopxEBMcn8ia8q6ziWs1BREQ466V9uDd4HGIk9kkq4CA2x6KWb6Fk3Ia4feYxjV8QUrcoT3xD5h5EpSW8j3wjeoQFpoDcDIFqih2vdA5ygJDKi3LRqmYk8eZR/GcS8TXAOO8ltCnwssDyGKnktz9I6QAGO+x8Q7bm1BI8=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=smIYx/tzY/f2aJmhhrXztdP2vSjB41gh/ELEcrrrYlkeKE/gu7SukvIHPFCVpGUVcfdlgvLrPl2B4wdWk2kWJ08z8W+3n2zDWpvcRqTNeqthiwbYgpk5PvkNEwteCXPUWx5jI2wFF7WLH36CB+OyeDT1lYYsSZyUHIBVcf3SpZA=;
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
Hello,
I'm in a bit of confusion, I'm writing a client using bufferevents, what I do is:
add a bunch of bufferevents to a base
set timeouts using the bufferevent timeout functions to 5-10s
and then dispatch the base, but this causes the base to return practically immediately, the connections get made, but, libevent doesn't seem to wait until the timeout is done, nor does it seem to wait forever, it just returns.
I have an eventcb + a readcb + a writecb set for each bev, and, my order of operations is:
Set up the bev, using bufferevent_socket_new, then I set the cbs using bufferevent_setcb, then I set up the timeval struct and set the timeouts, finally, I set the watermark to 0/1 (just to see if this makes a difference, it doesn't), i enable EV_READ|EV_WRITE on the bev, and then actually do bufferevent_socket_connect with it.
I do this in a loop(I've tried just a single event too), and then finally, do a event_base_dispatch(base), which returns practically immediately (all the conns are made, but.. it doesn't seem to wait for anything).
I get one callback before the base stops looping, on my event callback, with BEV_EVENT_CONNECTED.
so.. what am I doing wrong?
Right now, I've instead done this:
event_base_loopexit(base, &ten_sec);
while(1)
{
event_base_dispatch(base);
break;
}
This causes it to keep the connection alive for ten seconds (until the loop is exited), but, my timeout for the connection at this time is 5s.. the event does not timeout during this time.
I'm sure I'm doing something wrong, how do I get the functionality I want? is the above the only way? (The above would be fine, except I get no notification of closed events, so I can't handle them appropriately, I maintain some structs per event (in the callback ptr), that I'd like to take a look at before exiting.)
Any ideas?
Thank you!
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.