From 26e78029174b3c63a2898fea0931cb36749edc3d Mon Sep 17 00:00:00 2001 From: Kris Katterjohn Date: Fri, 23 Jun 2017 17:06:57 -0500 Subject: [PATCH] Stop depending on uninitialized variables when setting TCP_NODELAY The contents of an uninitialized variable was used when setting the TCP_NODELAY option for sockets created with open-client-stream and open-server-stream, so this option would not be set when the value of the variable happened to be 0 (which happened regularly on my OpenBSD box). Tested on OpenBSD and Linux. --- src/c/tcp.d | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/c/tcp.d b/src/c/tcp.d index c914aa992..ac6b1ecc5 100644 --- a/src/c/tcp.d +++ b/src/c/tcp.d @@ -133,11 +133,11 @@ int connect_to_server(char *host, int port) #ifdef TCP_NODELAY /* make sure to turn off TCP coalescence */ #if defined(ECL_MS_WINDOWS_HOST) - { char mi; + { char mi = 1; setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (char)); } #else - { int mi; + { int mi = 1; setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (int)); } #endif @@ -196,11 +196,11 @@ create_server_port(int port) #ifdef TCP_NODELAY /* make sure to turn off TCP coalescence */ #if defined(ECL_MS_WINDOWS_HOST) - { char mi; + { char mi = 1; setsockopt(request, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (char)); } #else - { int mi; + { int mi = 1; setsockopt(request, IPPROTO_TCP, TCP_NODELAY, &mi, sizeof (int)); } #endif