mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 15:26:04 +00:00
Merge pull request #1629 from hintjens/master
Problem: Windows 7 TCP slow start
This commit is contained in:
commit
22179afaba
@ -511,6 +511,27 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
|
|||||||
if (rc != SOCKET_ERROR)
|
if (rc != SOCKET_ERROR)
|
||||||
*r_ = accept (listener, NULL, NULL);
|
*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.
|
// Save errno if error occurred in bind/listen/connect/accept.
|
||||||
int saved_errno = 0;
|
int saved_errno = 0;
|
||||||
if (*r_ == INVALID_SOCKET)
|
if (*r_ == INVALID_SOCKET)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user