Skip to content

Commit 0187615

Browse files
authored
fix: close empty libp2p streams (#1920)
* close stream if no data * bump boost-graphsync
1 parent a209228 commit 0187615

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

datatransfer/network/libp2p_impl.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ func (dtnet *libp2pDataTransferNetwork) handleNewStream(s network.Stream) {
242242
for {
243243
var received datatransfer.Message
244244
var err error
245+
_ = s.SetReadDeadline(time.Now().Add(dtnet.sendMessageTimeout))
245246
switch s.Protocol() {
246247
case datatransfer.ProtocolDataTransfer1_2:
247248
received, err = message.FromNet(s)
@@ -253,9 +254,10 @@ func (dtnet *libp2pDataTransferNetwork) handleNewStream(s network.Stream) {
253254
go dtnet.receiver.ReceiveError(err)
254255
log.Debugf("net handleNewStream from %s error: %s", p, err)
255256
}
257+
_ = s.SetReadDeadline(time.Time{})
256258
return
257259
}
258-
260+
_ = s.SetReadDeadline(time.Time{})
259261
ctx := context.Background()
260262
log.Debugf("net handleNewStream from %s", p)
261263

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ require (
305305
)
306306

307307
require (
308-
github.com/filecoin-project/boost-graphsync v0.13.10
308+
github.com/filecoin-project/boost-graphsync v0.13.11
309309
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f
310310
github.com/filecoin-project/go-data-segment v0.0.1
311311
github.com/filecoin-project/lotus v1.26.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
316316
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
317317
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
318318
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
319-
github.com/filecoin-project/boost-graphsync v0.13.10 h1:L6qxpyognlcH73+vEPBXR8pbSMijXSV2CuV/sz0QDpA=
320-
github.com/filecoin-project/boost-graphsync v0.13.10/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
319+
github.com/filecoin-project/boost-graphsync v0.13.11 h1:quhAvlz+26D1xLH5v5XfWFfuxsZEcwbpbZxmF5ZNJzw=
320+
github.com/filecoin-project/boost-graphsync v0.13.11/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
321321
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f h1:8dd0yAadyeOL5Qd42XhEwD60UKvIFkY2MLhef/IaeOk=
322322
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231124125934-3233c510357f/go.mod h1:MyzvfYWAH0OAyf95TLUWYq3cO3vm/TVzDS57GKQi47o=
323323
github.com/filecoin-project/dagstore v0.7.0 h1:IS0R+69za8dguYWeqz/MI+nb7ONpk03tAkxPCBXEKm0=

go.work.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,7 @@ github.com/fatih/structs v0.0.0-20180123065059-ebf56d35bba7/go.mod h1:9NiDSp5zOc
13711371
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
13721372
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
13731373
github.com/felixge/httpsnoop v1.0.2/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
1374+
github.com/filecoin-project/boost-graphsync v0.13.11/go.mod h1:bc2M5ZLZJtXHl8kjnqtn4L1MsdEqpJErDaIeY0bJ9wk=
13741375
github.com/filecoin-project/boost/extern/boostd-data v0.0.0-20231009154452-ca8daa2870f3/go.mod h1:vHUM62fb82DpsBSXptQjpvcysjoV2Guc1MVJiIYccfQ=
13751376
github.com/filecoin-project/filecoin-ffi v0.30.4-0.20220519234331-bfd1f5f9fe38/go.mod h1:GM5pXRYvQM7wyH6V2WtPnJ2k1jt+qotRkWLxBSRCOuE=
13761377
github.com/filecoin-project/go-dagaggregator-unixfs v0.3.0 h1:UXLtBUnPa61LkNa2GqhP+aJ53bOnHP/dzg6/wk2rnsA=

0 commit comments

Comments
 (0)