Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Combine timers and streams/UDP sockets #657

kristrev opened this Issue Dec 17, 2012 · 3 comments


None yet
3 participants

kristrev commented Dec 17, 2012


I am working on an application were I want to combine a timer event and a UDP socket in the same event loop. I rely on the timer triggering more or less on time, in order to do some cleanup of client connections.

What I discovered is that the UDP socket "blocks" the timer from executing when it is supposed to, because of the loop in udp.c:208. My solution was to do a return after each packet was read, which solved the problem, but is most likely bad for applications requiring high throughput. When looking at the source code of the streams, it seems like they cause the same behavior.

Before I start working on a patch, I wondered if how I use libuv is wrong or if a patch/API change/... is already in the pipeline?


piscisaureus commented Dec 17, 2012


Yeah, the number of "spins" of that loop should have some upper limit. This has actually been fixed for streams already, we'd take a patch for UDP handles as well.


bnoordhuis commented Dec 17, 2012

Wasn't that fixed in 738b31e?


kristrev commented Dec 17, 2012

Yes, you are correct, there is an upper limit.

It turns out the mistake was all my fault. I created the socket manually and had forgotten to set it to nonblocking :( Thanks for the help and sorry about this!

@kristrev kristrev closed this Dec 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment