Skip SetKeepAlivePeriod call on OpenBSD
OpenBSD does not have a user-settable per-socket TCP keepalives. This changes
tryKeepAlive to skip attempting set it when on OpenBSD.
This prevents thousands of `log.Errorf("Failed set keepalive period: %s",
err)`'s from happening.
@@ -3,6 +3,7 @@ package tcp
import (
"context"
"net"
+ "runtime"
"time"
logging "github.com/ipfs/go-log"
@@ -41,10 +42,13 @@ func tryKeepAlive(conn net.Conn, keepAlive bool) {
log.Errorf("Failed to enable TCP keepalive: %s", err)
return
}
+
+ if runtime.GOOS != "openbsd" {
if err := keepAliveConn.SetKeepAlivePeriod(keepAlivePeriod); err != nil {
log.Errorf("Failed set keepalive period: %s", err)
}
}
+}
// try to set linger on the connection, if possible.
func tryLinger(conn net.Conn, sec int) {
