From cc2b0c9b1dc90aa6fd5d3fe63ea832fdcc0ba66a Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Thu, 18 Oct 2012 14:31:09 +0200 Subject: [PATCH] Set SO_KEEPALIVE before TCP_USER_TIMEOUT For TCP_USER_TIMEOUT to work it seems to be necessary that SO_KEEPALIVE is enabled. RFC5482 section 4.2 also says that the TCP_USER_TIMEOUT has to be less than the keepalive timeout. This means less than 30000 ms in the current libiscsi default settings for TCP keepalives. --- lib/socket.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/socket.c b/lib/socket.c index 0da1d95..9912976 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -160,13 +160,11 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, set_nonblocking(iscsi->fd); + iscsi_set_tcp_keepalive(iscsi, 30, 3, 30); + if (iscsi->tcp_user_timeout > 0) { set_tcp_user_timeout(iscsi); } - else - { - iscsi_set_tcp_keepalive(iscsi, 30, 3, 30); - } if (connect(iscsi->fd, ai->ai_addr, socksize) != 0 && errno != EINPROGRESS) {