Re: workqueue and pending

From: Andrew Morton
Date: Mon May 03 2004 - 18:29:20 EST


Mikkel Christiansen <mixxel@xxxxxxxxx> wrote:
>
> We're trying to use the workqueue interface for scheduling a delayed
> gargage collector.
> Since we only need a single delayed thread we used the DECLEARE_WORK macro.
>
> The problem is that once we call cancel_delayed_work we can't schedule
> work again.

It looks like nobody has tried to do that yet.

> Having looked at the code i noticed that cancel_delayed_work only
> deletes the timer but
> doesn't set clear the "pending" bit, thus any call to
> schedule_delayed_work is ignorred.

Does this work?

--- 25/include/linux/workqueue.h~cancel_delayed_work-fix Mon May 3 16:24:46 2004
+++ 25-akpm/include/linux/workqueue.h Mon May 3 16:26:01 2004
@@ -7,6 +7,7 @@

#include <linux/timer.h>
#include <linux/linkage.h>
+#include <linux/bitops.h>

struct workqueue_struct;

@@ -75,8 +76,11 @@ extern void init_workqueues(void);
*/
static inline int cancel_delayed_work(struct work_struct *work)
{
- return del_timer_sync(&work->timer);
+ int ret;
+
+ ret = del_timer_sync(&work->timer);
+ clear_bit(0, &work->pending);
+ return ret;
}

#endif
-

_

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/