1
0
mirror of https://github.com/Mrs4s/MiraiGo.git synced 2025-05-04 11:07:40 +08:00

fix socket block (#236)

This commit is contained in:
Lin 2022-01-06 20:52:09 +08:00 committed by GitHub
parent ab72f3dc28
commit 41a6cb05a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,7 @@ import (
"net" "net"
"net/http" "net/http"
"sync/atomic" "sync/atomic"
"time"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -48,7 +49,7 @@ type Input struct {
func (s *Session) Upload(addr Addr, input Input) error { func (s *Session) Upload(addr Addr, input Input) error {
fh, length := utils.ComputeMd5AndLength(input.Body) fh, length := utils.ComputeMd5AndLength(input.Body)
_, _ = input.Body.Seek(0, io.SeekStart) _, _ = input.Body.Seek(0, io.SeekStart)
conn, err := net.DialTCP("tcp", nil, addr.asTcpAddr()) conn, err := net.DialTimeout("tcp", addr.String(), time.Second*3)
if err != nil { if err != nil {
return errors.Wrap(err, "connect error") return errors.Wrap(err, "connect error")
} }