Cleanup a bit - don't need to lookup the protocol number if we just use the right define
Этот коммит содержится в:
родитель
69ac25bf55
Коммит
019bba5caf
@ -125,13 +125,9 @@ void orte_oob_tcp_set_socket_options(int sd)
|
||||
opal_socket_errno);
|
||||
return;
|
||||
}
|
||||
if (mca_oob_tcp_component.tcp_proto < 0) {
|
||||
/* we don't know the TCP protocol number */
|
||||
return;
|
||||
}
|
||||
#if defined(TCP_KEEPALIVE)
|
||||
/* set the idle time */
|
||||
if (setsockopt(sd, mca_oob_tcp_component.tcp_proto, TCP_KEEPALIVE,
|
||||
if (setsockopt(sd, IPPROTO_TCP, TCP_KEEPALIVE,
|
||||
&mca_oob_tcp_component.keepalive_time,
|
||||
sizeof(mca_oob_tcp_component.keepalive_time)) < 0) {
|
||||
opal_output(0, "[%s:%d] setsockopt(TCP_KEEPALIVE) failed: %s (%d)",
|
||||
@ -142,7 +138,7 @@ void orte_oob_tcp_set_socket_options(int sd)
|
||||
}
|
||||
#elif defined(TCP_KEEPIDLE)
|
||||
/* set the idle time */
|
||||
if (setsockopt(sd, mca_oob_tcp_component.tcp_proto, TCP_KEEPIDLE,
|
||||
if (setsockopt(sd, IPPROTO_TCP, TCP_KEEPIDLE,
|
||||
&mca_oob_tcp_component.keepalive_time,
|
||||
sizeof(mca_oob_tcp_component.keepalive_time)) < 0) {
|
||||
opal_output(0, "[%s:%d] setsockopt(TCP_KEEPIDLE) failed: %s (%d)",
|
||||
@ -154,7 +150,7 @@ void orte_oob_tcp_set_socket_options(int sd)
|
||||
#endif // TCP_KEEPIDLE
|
||||
#if defined(TCP_KEEPINTVL)
|
||||
/* set the keepalive interval */
|
||||
if (setsockopt(sd, mca_oob_tcp_component.tcp_proto, TCP_KEEPINTVL,
|
||||
if (setsockopt(sd, IPPROTO_TCP, TCP_KEEPINTVL,
|
||||
&mca_oob_tcp_component.keepalive_intvl,
|
||||
sizeof(mca_oob_tcp_component.keepalive_intvl)) < 0) {
|
||||
opal_output(0, "[%s:%d] setsockopt(TCP_KEEPINTVL) failed: %s (%d)",
|
||||
@ -166,7 +162,7 @@ void orte_oob_tcp_set_socket_options(int sd)
|
||||
#endif // TCP_KEEPINTVL
|
||||
#if defined(TCP_KEEPCNT)
|
||||
/* set the miss rate */
|
||||
if (setsockopt(sd, mca_oob_tcp_component.tcp_proto, TCP_KEEPCNT,
|
||||
if (setsockopt(sd, IPPROTO_TCP, TCP_KEEPCNT,
|
||||
&mca_oob_tcp_component.keepalive_probes,
|
||||
sizeof(mca_oob_tcp_component.keepalive_probes)) < 0) {
|
||||
opal_output(0, "[%s:%d] setsockopt(TCP_KEEPCNT) failed: %s (%d)",
|
||||
|
@ -411,21 +411,13 @@ static int tcp_component_register(void)
|
||||
#endif
|
||||
|
||||
|
||||
mca_oob_tcp_component.keepalive_time = -1;
|
||||
mca_oob_tcp_component.keepalive_time = 10;
|
||||
(void)mca_base_component_var_register(component, "keepalive_time",
|
||||
"Idle time in seconds before starting to send keepalives (num <= 0 => disable keepalive)",
|
||||
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
|
||||
OPAL_INFO_LVL_9,
|
||||
MCA_BASE_VAR_SCOPE_READONLY,
|
||||
&mca_oob_tcp_component.keepalive_time);
|
||||
if (0 < mca_oob_tcp_component.keepalive_time) {
|
||||
struct protoent *proto;
|
||||
if (NULL != (proto = getprotobyname("TCP"))) {
|
||||
mca_oob_tcp_component.tcp_proto = proto->p_proto;
|
||||
} else {
|
||||
mca_oob_tcp_component.tcp_proto = -1;
|
||||
}
|
||||
}
|
||||
|
||||
mca_oob_tcp_component.keepalive_intvl = 5;
|
||||
(void)mca_base_component_var_register(component, "keepalive_intvl",
|
||||
|
@ -80,7 +80,6 @@ typedef struct {
|
||||
int keepalive_probes; /**< number of keepalives that can be missed before declaring error */
|
||||
int keepalive_time; /**< idle time in seconds before starting to send keepalives */
|
||||
int keepalive_intvl; /**< time between keepalives, in seconds */
|
||||
int tcp_proto; /**< TCP protocol number */
|
||||
} mca_oob_tcp_component_t;
|
||||
|
||||
ORTE_MODULE_DECLSPEC extern mca_oob_tcp_component_t mca_oob_tcp_component;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user