Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/external/bsd/common/linux Don't let more than one thread...
details: https://anonhg.NetBSD.org/src/rev/a2b16844f4bd
branches: trunk
changeset: 366364:a2b16844f4bd
user: riastradh <riastradh%NetBSD.org@localhost>
date: Mon Aug 27 15:04:45 2018 +0000
description:
Don't let more than one thread claim credit for cancellation.
diffstat:
sys/external/bsd/common/linux/linux_work.c | 47 +++++++++++++++++++++++++----
1 files changed, 40 insertions(+), 7 deletions(-)
diffs (91 lines):
diff -r f72152128198 -r a2b16844f4bd sys/external/bsd/common/linux/linux_work.c
--- a/sys/external/bsd/common/linux/linux_work.c Mon Aug 27 15:04:32 2018 +0000
+++ b/sys/external/bsd/common/linux/linux_work.c Mon Aug 27 15:04:45 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_work.c,v 1.33 2018/08/27 15:04:32 riastradh Exp $ */
+/* $NetBSD: linux_work.c,v 1.34 2018/08/27 15:04:45 riastradh Exp $ */
/*-
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.33 2018/08/27 15:04:32 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_work.c,v 1.34 2018/08/27 15:04:45 riastradh Exp $");
#include <sys/types.h>
#include <sys/atomic.h>
@@ -964,8 +964,6 @@
}
break;
case DELAYED_WORK_SCHEDULED:
- case DELAYED_WORK_RESCHEDULED:
- case DELAYED_WORK_CANCELLED:
/*
* If it is scheduled, mark it cancelled and
* try to stop the callout before it starts.
@@ -982,6 +980,23 @@
if (!callout_stop(&dw->dw_callout))
cancel_delayed_work_done(wq, dw);
break;
+ case DELAYED_WORK_RESCHEDULED:
+ /*
+ * If it is being rescheduled, the callout has
+ * already fired. We must ask it to cancel.
+ */
+ dw->dw_state = DELAYED_WORK_CANCELLED;
+ cancelled_p = true;
+ break;
+ case DELAYED_WORK_CANCELLED:
+ /*
+ * If it is being cancelled, the callout has
+ * already fired. There is nothing more for us
+ * to do. Someone else claims credit for
+ * cancelling it.
+ */
+ cancelled_p = false;
+ break;
default:
panic("invalid delayed work state: %d",
dw->dw_state);
@@ -1029,8 +1044,6 @@
}
break;
case DELAYED_WORK_SCHEDULED:
- case DELAYED_WORK_RESCHEDULED:
- case DELAYED_WORK_CANCELLED:
/*
* If it is scheduled, mark it cancelled and
* try to stop the callout before it starts.
@@ -1046,9 +1059,29 @@
* dissociate it from the workqueue ourselves.
*/
dw->dw_state = DELAYED_WORK_CANCELLED;
- cancelled_p = true;
if (!callout_halt(&dw->dw_callout, &wq->wq_lock))
cancel_delayed_work_done(wq, dw);
+ cancelled_p = true;
+ break;
+ case DELAYED_WORK_RESCHEDULED:
+ /*
+ * If it is being rescheduled, the callout has
+ * already fired. We must ask it to cancel and
+ * wait for it to complete.
+ */
+ dw->dw_state = DELAYED_WORK_CANCELLED;
+ (void)callout_halt(&dw->dw_callout, &wq->wq_lock);
+ cancelled_p = true;
+ break;
+ case DELAYED_WORK_CANCELLED:
+ /*
+ * If it is being cancelled, the callout has
+ * already fired. We need only wait for it to
+ * complete. Someone else, however, claims
+ * credit for cancelling it.
+ */
+ (void)callout_halt(&dw->dw_callout, &wq->wq_lock);
+ cancelled_p = false;
break;
default:
panic("invalid delayed work state: %d",
Home |
Main Index |
Thread Index |
Old Index