Regd ev_timer
Jann Horn
jann+libev at thejh.net
Wed Apr 3 00:42:43 CEST 2013
On Wed, Apr 03, 2013 at 09:27:31AM +1100, Varun Chandramohan wrote:
> Hi Jann,
>
> Sorry for psudo code and bad format. I put only the pseudo code because it
> will easier to see if there is a logical flaw.
>
> This is not to check for internet connectivity. In my actual code I use IP
> address not resolving. This is just test code so I have the same. Please
> excuse me.
>
> With the changes you suggested
> This trick with the timer is a bit ugly. Why don't you do it the way it's
> documented in the manual? Just do
>
> ev_now_update(loop);
> ev_timer_set(&ps_hb->timer, DEFAULT_CONNECT_TIMER, 0);
>
> (same thing in hb_timeout_handler)
>
> This fixes my problem. It seem to work as expected.
Oh, cool, I didn't think that it was more than bad style. :)
> Iam pasting my code
> anyways so that you can take a look and let me know if you see proper use
> of the libev. Please
> add any comment. Thanks a lot for your help.
>
> My code: http://pastebin.com/Zvzurj2N
Sure. There are two things I can spot, but they're not libev-related:
1. After line 78 should be an indent, I think.
2. When a connect fails with an errno other than EINPROGRESS, you do a sleep()
without resetting the timer afterwards. Doesn't sound like a good idea.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20130403/aae2a3a8/attachment.pgp>
More information about the libev
mailing list