On windows platform, TCP_NODELAY can only be set when TCP is established. If the conection is not immediately returning success, call it when state is changed from TCP_CONNECTING to SSL_CONNECTING.
Signed-off-by: Linda Sun <[email protected]> --- lib/stream-ssl.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 3f753d1..8535088 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -220,6 +220,21 @@ want_to_poll_events(int want) } } +static inline 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) @@ -228,7 +243,6 @@ new_ssl_stream(const char *name, int fd, enum session_type type, socklen_t local_len = sizeof local; struct ssl_stream *sslv; SSL *ssl = NULL; - int on = 1; int retval; /* Check for all the needful configuration. */ @@ -260,13 +274,14 @@ new_ssl_stream(const char *name, int fd, enum session_type type, memset(&local, 0, sizeof local); } - /* Disable Nagle. */ - retval = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof on); - if (retval) { - retval = sock_errno(); - VLOG_ERR("%s: setsockopt(TCP_NODELAY): %s", name, - sock_strerror(retval)); - goto error; + /* Disable Nagle. + * 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; + } } /* Create and configure OpenSSL stream. */ @@ -455,6 +470,11 @@ ssl_connect(struct stream *stream) return retval; } sslv->state = STATE_SSL_CONNECTING; + /* Disable Nagle. */ + retval = setsockopt_tcp_nodelay(sslv->fd); + if (retval) { + return retval; + } /* Fall through. */ case STATE_SSL_CONNECTING: -- 1.7.9.5 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
