@@ -318,7 +318,6 @@ func (mq *MessageQueue) AddBroadcastWantHaves(wantHaves []cid.Cid) {
318
318
}
319
319
320
320
mq .wllock .Lock ()
321
- defer mq .wllock .Unlock ()
322
321
323
322
for _ , c := range wantHaves {
324
323
mq .bcstWants .Add (c , mq .priority , pb .Message_Wantlist_Have )
@@ -329,6 +328,8 @@ func (mq *MessageQueue) AddBroadcastWantHaves(wantHaves []cid.Cid) {
329
328
mq .cancels .Remove (c )
330
329
}
331
330
331
+ mq .wllock .Unlock ()
332
+
332
333
// Schedule a message send
333
334
mq .signalWorkReady ()
334
335
}
@@ -340,7 +341,6 @@ func (mq *MessageQueue) AddWants(wantBlocks []cid.Cid, wantHaves []cid.Cid) {
340
341
}
341
342
342
343
mq .wllock .Lock ()
343
- defer mq .wllock .Unlock ()
344
344
345
345
for _ , c := range wantHaves {
346
346
mq .peerWants .Add (c , mq .priority , pb .Message_Wantlist_Have )
@@ -359,6 +359,8 @@ func (mq *MessageQueue) AddWants(wantBlocks []cid.Cid, wantHaves []cid.Cid) {
359
359
mq .cancels .Remove (c )
360
360
}
361
361
362
+ mq .wllock .Unlock ()
363
+
362
364
// Schedule a message send
363
365
mq .signalWorkReady ()
364
366
}
@@ -844,7 +846,6 @@ FINISH:
844
846
now := mq .clock .Now ()
845
847
846
848
mq .wllock .Lock ()
847
- defer mq .wllock .Unlock ()
848
849
849
850
for _ , e := range peerEntries [:sentPeerEntries ] {
850
851
if e .Cid .Defined () { // Check if want was canceled in the interim
@@ -857,6 +858,9 @@ FINISH:
857
858
mq .bcstWants .SentAt (e .Cid , now )
858
859
}
859
860
}
861
+
862
+ mq .wllock .Unlock ()
863
+
860
864
if mq .events != nil {
861
865
mq .events <- messageFinishedSending
862
866
}
0 commit comments