@@ -483,6 +483,11 @@ public void run() {
483
483
System .out .printf ("Bulk transfer complete with %d bytes (wanted %d)\n " ,
484
484
res , msg .transferBufferLength );
485
485
}
486
+
487
+ if (!context .activeMessages .remove (msg )) {
488
+ // Somebody cancelled the URB, return without responding
489
+ return ;
490
+ }
486
491
487
492
if (res < 0 ) {
488
493
// If the request failed, let's see if the device is still around
@@ -500,7 +505,6 @@ public void run() {
500
505
reply .status = ProtoDefs .ST_OK ;
501
506
}
502
507
503
- context .activeMessages .remove (msg );
504
508
sendReply (s , reply , reply .status );
505
509
}
506
510
else if (selectedEndpoint .getType () == UsbConstants .USB_ENDPOINT_XFER_INT ) {
@@ -529,6 +533,11 @@ else if (selectedEndpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
529
533
System .out .printf ("Interrupt transfer complete with %d bytes (wanted %d)\n " ,
530
534
res , msg .transferBufferLength );
531
535
}
536
+
537
+ if (!context .activeMessages .remove (msg )) {
538
+ // Somebody cancelled the URB, return without responding
539
+ return ;
540
+ }
532
541
533
542
if (res < 0 ) {
534
543
reply .status = res ;
@@ -546,7 +555,6 @@ else if (selectedEndpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
546
555
reply .status = ProtoDefs .ST_OK ;
547
556
}
548
557
549
- context .activeMessages .remove (msg );
550
558
sendReply (s , reply , reply .status );
551
559
}
552
560
else {
@@ -617,6 +625,11 @@ public void submitUrbRequest(Socket s, UsbIpSubmitUrb msg) {
617
625
res = 0 ;
618
626
}
619
627
628
+ if (!context .activeMessages .remove (msg )) {
629
+ // Somebody cancelled the URB, return without responding
630
+ return ;
631
+ }
632
+
620
633
if (res < 0 ) {
621
634
// If the request failed, let's see if the device is still around
622
635
UsbDevice dev = getDevice (deviceId );
@@ -633,7 +646,6 @@ public void submitUrbRequest(Socket s, UsbIpSubmitUrb msg) {
633
646
reply .status = ProtoDefs .ST_OK ;
634
647
}
635
648
636
- context .activeMessages .remove (msg );
637
649
sendReply (s , reply , reply .status );
638
650
}
639
651
else {
0 commit comments