diff --git a/exchange/bitswap/wantmanager.go b/exchange/bitswap/wantmanager.go index 29f7b9469499..ef77ffde9591 100644 --- a/exchange/bitswap/wantmanager.go +++ b/exchange/bitswap/wantmanager.go @@ -145,10 +145,10 @@ func (mq *msgQueue) runQueue(ctx context.Context) { } func (mq *msgQueue) doWork(ctx context.Context) { - // allow a minute for connections + // allow ten minutes for connections // this includes looking them up in the dht // dialing them, and handshaking - conctx, cancel := context.WithTimeout(ctx, time.Minute) + conctx, cancel := context.WithTimeout(ctx, time.Minute*10) defer cancel() err := mq.network.ConnectTo(conctx, mq.p) @@ -161,14 +161,16 @@ func (mq *msgQueue) doWork(ctx context.Context) { // grab outgoing message mq.outlk.Lock() wlm := mq.out - mq.out = nil + if wlm != nil && !wlm.Empty() { + mq.out = nil + } mq.outlk.Unlock() if wlm == nil || wlm.Empty() { return } - sendctx, cancel := context.WithTimeout(ctx, time.Second*30) + sendctx, cancel := context.WithTimeout(ctx, time.Minute*5) defer cancel() // send wantlist updates