Merge pull request #102 from hintjens/master

Backported fix #1608
This commit is contained in:
Pieter Hintjens 2016-02-16 12:03:11 +01:00
commit cb811a1e0c
2 changed files with 25 additions and 1 deletions

5
NEWS
View File

@ -3,7 +3,10 @@
* Fixed #1673 - CMake on Windows put PDB in wrong directory.
* Fixed #1723 - Family is not set when resolving NIC on android.
* Fixed #1723 - Family is not set when resolving NIC on Android.
* Fixed #1608 - Windows 7 TCP slow start issue.
0MQ version 4.1.4 stable, released on 2015/12/18
================================================

View File

@ -454,6 +454,27 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
if (rc != SOCKET_ERROR)
*r_ = accept (listener, NULL, NULL);
// Send/receive large chunk to work around TCP slow start
// This code is a workaround for #1608
if (*r_ != INVALID_SOCKET) {
size_t dummy_size = 1024 * 1024; // 1M to overload default receive buffer
unsigned char *dummy = (unsigned char *) malloc (dummy_size);
int still_to_send = (int) dummy_size;
int still_to_recv = (int) dummy_size;
while (still_to_send || still_to_recv) {
int nbytes;
if (still_to_send > 0) {
nbytes = ::send (*w_, (char *) (dummy + dummy_size - still_to_send), still_to_send, 0);
wsa_assert (nbytes != SOCKET_ERROR);
still_to_send -= nbytes;
}
nbytes = ::recv (*r_, (char *) (dummy + dummy_size - still_to_recv), still_to_recv, 0);
wsa_assert (nbytes != SOCKET_ERROR);
still_to_recv -= nbytes;
}
free (dummy);
}
// Save errno if error occurred in bind/listen/connect/accept.
int saved_errno = 0;
if (*r_ == INVALID_SOCKET)