mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
stream-tcp: Call setsockopt TCP_NODELAY after TCP is connected.
On Windows platform, TCP_NODELAY can only be set when TCP is established. (This is an observed behavior and not written in any MSDN documentation.) The current code does not create any problems while running unit tests (because connections get established immediately) but is reportedly observed while connecting to a different machine. commit 8b76839(Move setsockopt TCP_NODELAY to when TCP is connected.) made changes to call setsockopt with TCP_NODELAY after TCP is connected only in lib/stream-ssl.c. We need the same change for stream-tcp too and this commit does that. Currently, a failure of setting TCP_NODELAY results in reporting the error and then closing the socket. This commit changes that behavior such that an error is reported if setting TCP_NODELAY fails, but the connection itself is not torn down. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
@@ -218,20 +218,6 @@ want_to_poll_events(int want)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
setsockopt_tcp_nodelay(int fd)
|
||||
{
|
||||
int on = 1;
|
||||
int retval;
|
||||
|
||||
retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on);
|
||||
if (retval) {
|
||||
retval = sock_errno();
|
||||
VLOG_ERR("setsockopt(TCP_NODELAY): %s", sock_strerror(retval));
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
new_ssl_stream(const char *name, int fd, enum session_type type,
|
||||
enum ssl_state state, struct stream **streamp)
|
||||
@@ -267,10 +253,7 @@ new_ssl_stream(const char *name, int fd, enum session_type type,
|
||||
* On windows platforms, this can only be called upon TCP connected.
|
||||
*/
|
||||
if (state == STATE_SSL_CONNECTING) {
|
||||
retval = setsockopt_tcp_nodelay(fd);
|
||||
if (retval) {
|
||||
goto error;
|
||||
}
|
||||
setsockopt_tcp_nodelay(fd);
|
||||
}
|
||||
|
||||
/* Create and configure OpenSSL stream. */
|
||||
@@ -454,10 +437,7 @@ ssl_connect(struct stream *stream)
|
||||
return retval;
|
||||
}
|
||||
sslv->state = STATE_SSL_CONNECTING;
|
||||
retval = setsockopt_tcp_nodelay(sslv->fd);
|
||||
if (retval) {
|
||||
return retval;
|
||||
}
|
||||
setsockopt_tcp_nodelay(sslv->fd);
|
||||
/* Fall through. */
|
||||
|
||||
case STATE_SSL_CONNECTING:
|
||||
|
Reference in New Issue
Block a user