summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-transport/socket
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/rpc-transport/socket')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c106
-rw-r--r--rpc/rpc-transport/socket/src/socket.h12
2 files changed, 64 insertions, 54 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index 120e193ddf1..615f69f1b5a 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -2048,30 +2048,24 @@ socket_connect (rpc_transport_t *this, int port)
/* Cant help if setting socket options fails. We can continue
* working nonetheless.
*/
- if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF,
- &priv->windowsize,
- sizeof (priv->windowsize)) < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "setting receive window size failed: %d: %d: "
- "%s", priv->sock, priv->windowsize,
- strerror (errno));
- }
-
- if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF,
- &priv->windowsize,
- sizeof (priv->windowsize)) < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "setting send window size failed: %d: %d: "
- "%s", priv->sock, priv->windowsize,
- strerror (errno));
- }
-
+ if (priv->windowsize != 0) {
+ if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF,
+ &priv->windowsize,
+ sizeof (priv->windowsize)) < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting receive window "
+ "size failed: %d: %d: %s",
+ priv->sock, priv->windowsize,
+ strerror (errno));
+ }
- if (priv->nodelay) {
- ret = __socket_nodelay (priv->sock);
- if (ret == -1) {
+ if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF,
+ &priv->windowsize,
+ sizeof (priv->windowsize)) < 0) {
gf_log (this->name, GF_LOG_ERROR,
- "setsockopt() failed for NODELAY (%s)",
+ "setting send window size "
+ "failed: %d: %d: %s",
+ priv->sock, priv->windowsize,
strerror (errno));
}
}
@@ -2204,22 +2198,26 @@ socket_listen (rpc_transport_t *this)
/* Cant help if setting socket options fails. We can continue
* working nonetheless.
*/
- if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF,
- &priv->windowsize,
- sizeof (priv->windowsize)) < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "setting receive window size failed: %d: %d: "
- "%s", priv->sock, priv->windowsize,
- strerror (errno));
- }
+ if (priv->windowsize != 0) {
+ if (setsockopt (priv->sock, SOL_SOCKET, SO_RCVBUF,
+ &priv->windowsize,
+ sizeof (priv->windowsize)) < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting receive window size "
+ "failed: %d: %d: %s", priv->sock,
+ priv->windowsize,
+ strerror (errno));
+ }
- if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF,
- &priv->windowsize,
- sizeof (priv->windowsize)) < 0) {
- gf_log (this->name, GF_LOG_ERROR,
- "setting send window size failed: %d: %d: "
- "%s", priv->sock, priv->windowsize,
- strerror (errno));
+ if (setsockopt (priv->sock, SOL_SOCKET, SO_SNDBUF,
+ &priv->windowsize,
+ sizeof (priv->windowsize)) < 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "setting send window size failed:"
+ " %d: %d: %s", priv->sock,
+ priv->windowsize,
+ strerror (errno));
+ }
}
if (priv->nodelay) {
@@ -2510,10 +2508,11 @@ struct rpc_transport_ops tops = {
int
reconfigure (rpc_transport_t *this, dict_t *options)
{
- socket_private_t *priv = NULL;
- gf_boolean_t tmp_bool = _gf_false;
- char *optstr = NULL;
- int ret = 0;
+ socket_private_t *priv = NULL;
+ gf_boolean_t tmp_bool = _gf_false;
+ char *optstr = NULL;
+ int ret = 0;
+ uint64_t windowsize = 0;
GF_VALIDATE_OR_GOTO ("socket", this, out);
GF_VALIDATE_OR_GOTO ("socket", this->private, out);
@@ -2541,6 +2540,19 @@ reconfigure (rpc_transport_t *this, dict_t *options)
}
else
priv->keepalive = 1;
+
+ optstr = NULL;
+ if (dict_get_str (this->options, "tcp-window-size",
+ &optstr) == 0) {
+ if (gf_string2bytesize (optstr, &windowsize) != 0) {
+ gf_log (this->name, GF_LOG_ERROR,
+ "invalid number format: %s", optstr);
+ goto out;
+ }
+ }
+
+ priv->windowsize = (int)windowsize;
+
ret = 0;
out:
return ret;
@@ -2620,9 +2632,8 @@ socket_init (rpc_transport_t *this)
}
}
-
optstr = NULL;
- if (dict_get_str (this->options, "transport.window-size",
+ if (dict_get_str (this->options, "tcp-window-size",
&optstr) == 0) {
if (gf_string2bytesize (optstr, &windowsize) != 0) {
gf_log (this->name, GF_LOG_ERROR,
@@ -2631,8 +2642,9 @@ socket_init (rpc_transport_t *this)
}
}
- optstr = NULL;
+ priv->windowsize = (int)windowsize;
+ optstr = NULL;
/* Enable Keep-alive by default. */
priv->keepalive = 1;
priv->keepaliveintvl = 2;
@@ -2684,7 +2696,7 @@ socket_init (rpc_transport_t *this)
}
}
- priv->windowsize = (int)windowsize;
+ optstr = NULL;
out:
this->private = priv;
@@ -2766,10 +2778,10 @@ struct volume_options options[] = {
{ .key = {"non-blocking-io"},
.type = GF_OPTION_TYPE_BOOL
},
- { .key = {"transport.window-size"},
+ { .key = {"tcp-window-size"},
.type = GF_OPTION_TYPE_SIZET,
.min = GF_MIN_SOCKET_WINDOW_SIZE,
- .max = GF_MAX_SOCKET_WINDOW_SIZE,
+ .max = GF_MAX_SOCKET_WINDOW_SIZE
},
{ .key = {"transport.socket.nodelay"},
.type = GF_OPTION_TYPE_BOOL
diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h
index 7f0fb6bc356..082977a2ac5 100644
--- a/rpc/rpc-transport/socket/src/socket.h
+++ b/rpc/rpc-transport/socket/src/socket.h
@@ -41,19 +41,17 @@
#define RPC_MAX_FRAGMENT_SIZE 0x7fffffff
-/* This is the size set through setsockopt for
- * both the TCP receive window size and the
- * send buffer size.
- * Till the time iobuf size becomes configurable, this size is set to include
- * two iobufs + the GlusterFS protocol headers.
+/* The default window size will be 0, indicating not to set
+ * it to any size. Default size of Linux is found to be
+ * performance friendly.
* Linux allows us to over-ride the max values for the system.
* Should we over-ride them? Because if we set a value larger than the default
* setsockopt will fail. Having larger values might be beneficial for
* IB links.
*/
-#define GF_DEFAULT_SOCKET_WINDOW_SIZE (512 * GF_UNIT_KB)
+#define GF_DEFAULT_SOCKET_WINDOW_SIZE (0)
#define GF_MAX_SOCKET_WINDOW_SIZE (1 * GF_UNIT_MB)
-#define GF_MIN_SOCKET_WINDOW_SIZE (128 * GF_UNIT_KB)
+#define GF_MIN_SOCKET_WINDOW_SIZE (0)
#define GF_USE_DEFAULT_KEEPALIVE (-1)
typedef enum {