File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -418,6 +418,7 @@ void equeue_dispatch(equeue_t *q, int ms) {
418
418
q -> background .active = true;
419
419
equeue_mutex_unlock (& q -> queuelock );
420
420
}
421
+ q -> break_requested = false;
421
422
return ;
422
423
}
423
424
}
Original file line number Diff line number Diff line change @@ -687,6 +687,45 @@ void multithreaded_barrage_test(int N) {
687
687
equeue_destroy (& q );
688
688
}
689
689
690
+ struct sCaQ
691
+ {
692
+ int p ;
693
+ equeue_t * q ;
694
+ };
695
+
696
+ typedef struct sCaQ CountAndQueue ;
697
+
698
+ void simple_breaker (void * p ) {
699
+ CountAndQueue * caq = (CountAndQueue * )p ;
700
+ equeue_break (caq -> q );
701
+ usleep (10000 );
702
+ caq -> p ++ ;
703
+ }
704
+
705
+ void break_request_cleared_on_timeout (void ) {
706
+ equeue_t q ;
707
+ int err = equeue_create (& q , 2048 );
708
+ test_assert (!err );
709
+
710
+ CountAndQueue pq ;
711
+ pq .p = 0 ;
712
+ pq .q = & q ;
713
+
714
+ int id = equeue_call_every (& q , 10 , simple_breaker , & pq );
715
+
716
+ equeue_dispatch (& q , 10 );
717
+ test_assert (pq .p == 1 );
718
+
719
+ equeue_cancel (& q , id );
720
+
721
+ int count = 0 ;
722
+ equeue_call_every (& q , 10 , simple_func , & count );
723
+
724
+ equeue_dispatch (& q , 55 );
725
+ test_assert (count > 1 );
726
+
727
+ equeue_destroy (& q );
728
+ }
690
729
691
730
int main () {
692
731
printf ("beginning tests...\n" );
@@ -712,6 +751,7 @@ int main() {
712
751
test_run (simple_barrage_test , 20 );
713
752
test_run (fragmenting_barrage_test , 20 );
714
753
test_run (multithreaded_barrage_test , 20 );
754
+ test_run (break_request_cleared_on_timeout );
715
755
716
756
printf ("done!\n" );
717
757
return test_failure ;
You can’t perform that action at this time.
0 commit comments