diff options
author | Shehjar Tikoo <shehjart@gluster.com> | 2009-05-26 03:40:16 +0000 |
---|---|---|
committer | Anand V. Avati <avati@dev.gluster.com> | 2009-05-26 02:30:43 -0700 |
commit | 78ed845bc98ced0b2edd14875f5a7ef755802984 (patch) | |
tree | 3d428c842675317e05334c4509eb2eb0cb2ad2b2 /transport/socket/src/socket.c | |
parent | 71406e395f5cd4da495060d5604fe7db2d4018d1 (diff) |
socket: Set receive and send window size
This is experimental. We're hoping this improve performance on
high speed links like 10GigE.
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
Diffstat (limited to 'transport/socket/src/socket.c')
-rw-r--r-- | transport/socket/src/socket.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c index 49312f7b20a..65c17763d13 100644 --- a/transport/socket/src/socket.c +++ b/transport/socket/src/socket.c @@ -996,6 +996,27 @@ socket_connect (transport_t *this) goto unlock; } + /* 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->xl->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->xl->name, GF_LOG_ERROR, + "setting send window size failed: %d: %d: " + "%s", priv->sock, priv->windowsize, + strerror (errno)); + } + if (!priv->bio) { ret = __socket_nonblock (priv->sock); @@ -1106,6 +1127,27 @@ socket_listen (transport_t *this) goto unlock; } + /* 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->xl->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->xl->name, GF_LOG_ERROR, + "setting send window size failed: %d: %d: " + "%s", priv->sock, priv->windowsize, + strerror (errno)); + } + if (!priv->bio) { ret = __socket_nonblock (priv->sock); @@ -1279,6 +1321,8 @@ socket_init (transport_t *this) socket_private_t *priv = NULL; gf_boolean_t tmp_bool = 0; char *nb_connect = NULL; + uint64_t windowsize = GF_DEFAULT_SOCKET_WINDOW_SIZE; + char *wsizestr = NULL; if (this->private) { gf_log (this->xl->name, GF_LOG_DEBUG, @@ -1320,6 +1364,14 @@ socket_init (transport_t *this) } } + if (dict_get_str (this->xl->options, "window-size", &wsizestr) == 0) { + if (gf_string2bytesize (wsizestr, &windowsize) != 0) { + gf_log (this->xl->name, GF_LOG_ERROR, + "invalid number format: %s", wsizestr); + return -1; + } + } + priv->windowsize = (int)windowsize; this->private = priv; return 0; @@ -1380,6 +1432,11 @@ struct volume_options options[] = { "unix", "inet-sdp" }, .type = GF_OPTION_TYPE_STR }, + { .key = {"transport.window-size"}, + .type = GF_OPTION_TYPE_SIZET, + .min = GF_MIN_SOCKET_WINDOW_SIZE, + .max = GF_MAX_SOCKET_WINDOW_SIZE, + }, { .key = {NULL} } }; |