Skip to content

Conversation

@saghul
Copy link
Member

@saghul saghul commented May 27, 2015

R=@bnoordhuis

Fixes: #301

@saghul
Copy link
Member Author

saghul commented May 27, 2015

Well, fuck.I'm afraid the change to uv__run_pending has some interesting side effects, as in 40 failing tests or something :-(

@saghul
Copy link
Member Author

saghul commented May 27, 2015

The problem seems to be the following:

  • The first time around, uv_udp_send sends immediately, so uv__udp_sendmsg is called and the io handle is set as pending with uv__io_feed, in order to run the callback on the next tick.
  • On the next tick, while in uv__run_pending, we call uv_udp_send again, and because we get UV__POLLOUT, we also try to write the queued send requests, and we succeed! so we call uv__io_feed again, to call its callback.
  • Since we're ietarting the pending queue, and uv__io_feed adds the handle to that very same queue, we enter an infinite loop.

I'll keep digging...

@saghul
Copy link
Member Author

saghul commented May 27, 2015

Solved it! All tests pass, it was a fuckup in using QUEUE_FOREACH. @bnoordhuis can you PTAL?

@bnoordhuis
Copy link
Member

LGTM

@saghul saghul merged commit 1816dbc into libuv:v1.x May 28, 2015
@saghul
Copy link
Member Author

saghul commented May 28, 2015

Thanks Ben! Adjusted the comment and landed.

saghul added 2 commits May 28, 2015 11:05
If any of the callbacks called in uv__run_pending calls
uv__io_feed we enter an infinite loop, because we add the handle to the
same queue we are iterating over.

Refs: libuv#301
PR-URL: libuv#371
Reviewed-By: Ben Noordhuis <[email protected]>
saghul added a commit to saghul/node that referenced this pull request Jun 3, 2015
Revert "dgram: call send callback asynchronously" partially, since the
fix is now done in libuv.

Refs: nodejs#1313
Refs: libuv/libuv#371
bnoordhuis pushed a commit to nodejs/node that referenced this pull request Jun 3, 2015
Revert "dgram: call send callback asynchronously" partially, since the
fix is now done in libuv.

Refs: #1313
Refs: libuv/libuv#371
PR-URL: #1889
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
guworks pushed a commit to guworks/libuv that referenced this pull request Jul 9, 2015
If any of the callbacks called in uv__run_pending calls
uv__io_feed we enter an infinite loop, because we add the handle to the
same queue we are iterating over.

Refs: libuv#301
PR-URL: libuv#371
Reviewed-By: Ben Noordhuis <[email protected]>
guworks pushed a commit to guworks/libuv that referenced this pull request Jul 9, 2015
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
If any of the callbacks called in uv__run_pending calls
uv__io_feed we enter an infinite loop, because we add the handle to the
same queue we are iterating over.

Refs: libuv#301
PR-URL: libuv#371
Reviewed-By: Ben Noordhuis <[email protected]>
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
If any of the callbacks called in uv__run_pending calls
uv__io_feed we enter an infinite loop, because we add the handle to the
same queue we are iterating over.

Refs: libuv#301
PR-URL: libuv#371
Reviewed-By: Ben Noordhuis <[email protected]>
skomski pushed a commit to skomski/libuv that referenced this pull request Aug 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

udp: callbacks are effectively synchronous

2 participants