int grabFlowControlBytes ( int bytesToGrab ) { if ( bytesToGrab <= 0 ) { return 0 ; } int min ; synchronized ( flowControlLock ) { min = ( int ) Math . min ( bytesToGrab , sendWindowSize ) ; if ( bytesToGrab > FLOW_CONTROL_MIN_WINDOW && min <= FLOW_CONTROL_MIN_WINDOW ) { //this can cause problems with padding, so we just return 0 return 0 ; } min = Math . min ( sendMaxFrameSize , min ) ; sendWindowSize -= min ; } return min ; }
Try and decrement the send window by the given amount of bytes .