Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WifiClient::write refactoring (second attempt) #2177

Merged
merged 3 commits into from
Jun 23, 2016
Merged

Conversation

igrr
Copy link
Member

@igrr igrr commented Jun 22, 2016

Another attempt to do the same thing as in #1570.

WiFiClient::write used to block for every call until data was acknowledged by remote side. This also meant that for a series of WiFiClient::write or WiFiClient::print calls, each call would actually invoke tcp_output to send data and wait for acknowledgement, making the whole process really slow. Also with that design WiFiClient::setNoDelay didn't have any effect — because Nagle algorithm was never used in the first place.

With this change, WiFiClient::write will return as soon as all supplied data has been passed to the TCP stack. In practice that means that as much as 2 * 1460 bytes can be sent before WiFiClient::write will block. This change also changes WiFiClient::write behaviour for large blocks of data. Previously it would only write as much as TCP stack was willing to take (usually 2 * 1460 bytes) and not more. Now write method actually tries to send all data, i.e. if all data can not be sent at once, it will wait for more buffer space to be available and then send the rest. I'm also considering adding WiFiClient::setNonBlocking(bool) method to disable blocking altogether.

This change also removes all split-into-chunks-and-write code from ESP8266WebServer library because this is now handled by WiFiClient.

@codecov-io
Copy link

Current coverage is 27.61%

Merging #2177 into master will not change coverage

@@             master      #2177   diff @@
==========================================
  Files            20         20          
  Lines          3686       3686          
  Methods         337        337          
  Messages          0          0          
  Branches        678        678          
==========================================
  Hits           1018       1018          
  Misses         2490       2490          
  Partials        178        178          

Powered by Codecov. Last updated by 3e34c75...7a439b4

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

Successfully merging this pull request may close these issues.

2 participants