Pārlūkot izejas kodu

Add flush_workqueue before destroying workqueue

To ensure no work is left running when the module is removed, call
flush_workqueue() before destroy_workqueue() in the module exit path.
According to the kernel documentation, destroy_workqueue() expects
that all work items have already completed:

    "Safely destroy a workqueue. All work currently pending will be
    done first."

This change adds an explicit call to flush_workqueue() in the module
exit function to ensure no work handler remains in progress or pending
at the time of destruction.
Guan-Chun.Wu 2 dienas atpakaļ
vecāks
revīzija
b30af6bf36
1 mainītis faili ar 1 papildinājumiem un 0 dzēšanām
  1. 1 0
      examples/sched.c

+ 1 - 0
examples/sched.c

@@ -27,6 +27,7 @@ static int __init sched_init(void)
 
 static void __exit sched_exit(void)
 {
+    flush_workqueue(queue);
     destroy_workqueue(queue);
 }