jvburnes / node9

A portable hybrid distributed OS based on Inferno, LuaJIT and Libuv
MIT License
410 stars 32 forks source link

Quick hack to account for async evens getting coalesced #15

Open rvs opened 3 years ago

rvs commented 3 years ago

While playing with node9 on both Mac OS X and Linux over the holidays, I kept running into a weird issue where if I cut-n-paste any text string into the console -- the console driver would get behind a random number of characters and not deliver strings back to the shell when I pressed enter. After some investigation it turns out that libav doesn't have a guarantee that X uv_async_send events would trigger exactly X wakeups of a handler. In fact, the handler may actually get woken up anywhere between 1 and X times (but at least one is guaranteed). This, of course, explains why I would see this 'console driver getting behind issue' and suggests a very simply fix along the lines of this PR.

We should probably turn it into a proper while loop if this gets to be the way we fix this issue, but I wanted to show the idea in the smallest diff possible first.

@jvburnes please let me know WDYT