Skip to content

Commit

Permalink
guards (unnecessary, but why not)
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Feb 2, 2025
1 parent be0db92 commit fb9316d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17538,6 +17538,8 @@ FIO_IFUNC fio___timer_event_s *fio___timer_event_new(

FIO_IFUNC void fio___timer_event_free(fio_timer_queue_s *tq,
fio___timer_event_s *t) {
if (!t)
return;
if (tq && (t->repetitions < 0 || fio_atomic_sub_fetch(&t->repetitions, 1))) {
FIO___LOCK_LOCK(tq->lock);
fio___timer_insert(&tq->next, t);
Expand Down Expand Up @@ -17614,15 +17616,16 @@ SFUNC void fio_timer_schedule FIO_NOOP(fio_timer_queue_s *timer,
* they repeat).
*/
SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) {
fio___timer_event_s *next;
if (!tq)
return;
fio___timer_event_s *next = NULL;
FIO___LOCK_LOCK(tq->lock);
next = tq->next;
tq->next = NULL;
FIO___LOCK_UNLOCK(tq->lock);
FIO___LOCK_DESTROY(tq->lock);
while (next) {
fio___timer_event_s *tmp = next;

next = next->next;
fio___timer_event_free(NULL, tmp);
}
Expand Down
7 changes: 5 additions & 2 deletions fio-stl/102 queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,8 @@ FIO_IFUNC fio___timer_event_s *fio___timer_event_new(

FIO_IFUNC void fio___timer_event_free(fio_timer_queue_s *tq,
fio___timer_event_s *t) {
if (!t)
return;
if (tq && (t->repetitions < 0 || fio_atomic_sub_fetch(&t->repetitions, 1))) {
FIO___LOCK_LOCK(tq->lock);
fio___timer_insert(&tq->next, t);
Expand Down Expand Up @@ -739,15 +741,16 @@ SFUNC void fio_timer_schedule FIO_NOOP(fio_timer_queue_s *timer,
* they repeat).
*/
SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) {
fio___timer_event_s *next;
if (!tq)
return;
fio___timer_event_s *next = NULL;
FIO___LOCK_LOCK(tq->lock);
next = tq->next;
tq->next = NULL;
FIO___LOCK_UNLOCK(tq->lock);
FIO___LOCK_DESTROY(tq->lock);
while (next) {
fio___timer_event_s *tmp = next;

next = next->next;
fio___timer_event_free(NULL, tmp);
}
Expand Down

0 comments on commit fb9316d

Please sign in to comment.