Closed TravisWhitaker closed 5 years ago
Oh you're right. I feel like it was a monadic effect for some reason and never got to implement it entirely! Thanks, this patch is much appreciated.
Can you open another issue for the potential race conditions + if you have some time and ideas on how to improve it. I'll be on a trip soon and won't have much time before end of May.
This fixes a bug which could cause
_withdrawCredit
from a connection'sOutgoingFlowControl
to spin forever. Without this patch,getBase
innewOutgoingFlowControl
would always return the default initial window size, even if we had received an updated window size from the server. If the server sets an initial window size not equal to the default,waitSettingsChange
would almost always win the race againstwaitSomeCredit
, causingwithdraw
to spin forever.The current definition of
withdraw
is still problematic, consider this ordering:waitSomeCredit
finishes its call toreadChan frames
.waitSettingsChange
returns, winning therace
.withdraw
callsreceive 0
and recurses.waitSomeCredit
is lost.With this patch this bad ordering should be exceedingly rare; without this patch, it happens almost every time we run out of outgoing credit!