1
0
mirror of https://github.com/matrix-org/pinecone.git synced 2026-10-24 11:59:18 +03:00

Tweaks to TCP timeouts in pineconeip

This commit is contained in:
Neil Alexander
2021-05-12 17:24:19 +01:00
parent 1870724388
commit e41358c16a

View File

@@ -15,12 +15,14 @@
package main
import (
"context"
"crypto/ed25519"
"flag"
"fmt"
"log"
"net"
"os"
"time"
"net/http"
_ "net/http/pprof"
@@ -36,6 +38,14 @@ func main() {
panic(err)
}
dialer := net.Dialer{
Timeout: time.Second * 5,
KeepAlive: time.Second * 3,
}
listener := net.ListenConfig{
KeepAlive: time.Second * 3,
}
logger := log.New(os.Stdout, "", 0)
if hostPort := os.Getenv("PPROFLISTEN"); hostPort != "" {
logger.Println("Starting pprof on", hostPort)
@@ -59,7 +69,7 @@ func main() {
if connect != nil && *connect != "" {
go func() {
conn, err := net.Dial("tcp", *connect)
conn, err := dialer.Dial("tcp", *connect)
if err != nil {
panic(err)
}
@@ -74,7 +84,7 @@ func main() {
}
go func() {
listener, err := net.Listen("tcp", *listen)
listener, err := listener.Listen(context.Background(), "tcp", *listen)
if err != nil {
panic(err)
}