Skip to content

Commit

Permalink
fix: close empty libp2p streams (#1920)
Browse files Browse the repository at this point in the history
* close stream if no data

* bump boost-graphsync
  • Loading branch information
LexLuthr authored May 20, 2024
1 parent a209228 commit 0187615
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
4 changes: 3 additions & 1 deletion datatransfer/network/libp2p_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ func (dtnet *libp2pDataTransferNetwork) handleNewStream(s network.Stream) {
for {
var received datatransfer.Message
var err error
_ = s.SetReadDeadline(time.Now().Add(dtnet.sendMessageTimeout))
switch s.Protocol() {
case datatransfer.ProtocolDataTransfer1_2:
received, err = message.FromNet(s)
Expand All @@ -253,9 +254,10 @@ func (dtnet *libp2pDataTransferNetwork) handleNewStream(s network.Stream) {
go dtnet.receiver.ReceiveError(err)
log.Debugf("net handleNewStream from %s error: %s", p, err)
}
_ = s.SetReadDeadline(time.Time{})
return
}

_ = s.SetReadDeadline(time.Time{})
ctx := context.Background()
log.Debugf("net handleNewStream from %s", p)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ require (
)

require (
github.com/filecoin-project/boost-graphsync v0.13.10
github.com/filecoin-project/boost-graphsync v0.13.11
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f
github.com/filecoin-project/go-data-segment v0.0.1
github.com/filecoin-project/lotus v1.26.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/filecoin-project/boost-graphsync v0.13.10 h1:L6qxpyognlcH73+vEPBXR8pbSMijXSV2CuV/sz0QDpA=
github.com/filecoin-project/boost-graphsync v0.13.10/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
github.com/filecoin-project/boost-graphsync v0.13.11 h1:quhAvlz+26D1xLH5v5XfWFfuxsZEcwbpbZxmF5ZNJzw=
github.com/filecoin-project/boost-graphsync v0.13.11/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f h1:8dd0yAadyeOL5Qd42XhEwD60UKvIFkY2MLhef/IaeOk=
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f/go.mod h1:MyzvfYWAH0OAyf95TLUWYq3cO3vm/TVzDS57GKQi47o=
github.com/filecoin-project/dagstore v0.7.0 h1:IS0R+69za8dguYWeqz/MI+nb7ONpk03tAkxPCBXEKm0=
Expand Down
1 change: 1 addition & 0 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1371,6 +1371,7 @@ github.com/fatih/structs v0.0.0-20180123065059-ebf56d35bba7/go.mod h1:9NiDSp5zOc
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/filecoin-project/boost-graphsync v0.13.11/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231009154452-ca8daa2870f3/go.mod h1:vHUM62fb82DpsBSXptQjpvcysjoV2Guc1MVJiIYccfQ=
github.com/filecoin-project/filecoin-ffi v0.30.4-0.20220519234331-bfd1f5f9fe38/go.mod h1:GM5pXRYvQM7wyH6V2WtPnJ2k1jt+qotRkWLxBSRCOuE=
github.com/filecoin-project/go-dagaggregator-unixfs v0.3.0 h1:UXLtBUnPa61LkNa2GqhP+aJ53bOnHP/dzg6/wk2rnsA=
Expand Down

0 comments on commit 0187615

Please sign in to comment.