always export iscsi_set_tcp_keepalive()
Set only the (socket) options which are defined on a given platform. The function becomes a no-op if no option is known at complie time. Remove autoconf test for HAVE_TCP_KEEPALIVE too. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
committed by
Ronnie Sahlberg
parent
c91de1e35a
commit
aee0e3bf72
15
lib/socket.c
15
lib/socket.c
@@ -460,9 +460,7 @@ iscsi_service(struct iscsi_context *iscsi, int revents)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_TCP_KEEPALIVE
|
||||
iscsi_set_tcp_keepalive(iscsi, 30, 3, 30);
|
||||
#endif
|
||||
iscsi->is_connected = 1;
|
||||
iscsi->socket_status_cb(iscsi, SCSI_STATUS_GOOD, NULL,
|
||||
iscsi->connect_data);
|
||||
@@ -540,39 +538,42 @@ iscsi_free_iscsi_inqueue(struct iscsi_in_pdu *inqueue)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_TCP_KEEPALIVE
|
||||
int iscsi_set_tcp_keepalive(struct iscsi_context *iscsi, int idle, int count, int interval)
|
||||
{
|
||||
int value;
|
||||
|
||||
#ifdef SO_KEEPALIVE
|
||||
value =1;
|
||||
if (setsockopt(iscsi->fd, SOL_SOCKET, SO_KEEPALIVE, &value, sizeof(value)) != 0) {
|
||||
iscsi_set_error(iscsi, "TCP: Failed to set socket option SO_KEEPALIVE. Error %s(%d)", strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef TCP_KEEPCNT
|
||||
value = count;
|
||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPCNT, &value, sizeof(value)) != 0) {
|
||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive count. Error %s(%d)", strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef TCP_KEEPINTVL
|
||||
value = interval;
|
||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPINTVL, &value, sizeof(value)) != 0) {
|
||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive interval. Error %s(%d)", strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef TCP_KEEPIDLE
|
||||
value = idle;
|
||||
if (setsockopt(iscsi->fd, SOL_TCP, TCP_KEEPIDLE, &value, sizeof(value)) != 0) {
|
||||
iscsi_set_error(iscsi, "TCP: Failed to set tcp keepalive idle. Error %s(%d)", strerror(errno), errno);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
#if defined(WIN32)
|
||||
int poll(struct pollfd *fds, int nfsd, int timeout)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user