[Devel,1/2] new helper: wait_event_killable_exclusive()

Submitted by Stanislav Kinsburskiy on Oct. 13, 2016, 10:03 a.m.

Details

Message ID 20161013100340.27083.25816.stgit@localhost.localdomain
State New
Series "fuse: fix signals handling while processing request"
Headers show

Commit Message

Stanislav Kinsburskiy Oct. 13, 2016, 10:03 a.m.
Backport of 6a0fb306738994d6f091791aeb11a5dc87ad8f4c.

Signed-off-by: Stanislav Kinsburskiy <skinsbursky@virtuozzo.com>
---
 include/linux/wait.h |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Patch hide | download patch | download mbox

diff --git a/include/linux/wait.h b/include/linux/wait.h
index 65da9e3..8475f2d 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -710,6 +710,32 @@  do {									\
 	__ret;								\
 })
 
+#define __wait_event_killable_exclusive(wq, condition, ret)		\
+do {									\
+	DEFINE_WAIT(__wait);						\
+									\
+	for (;;) {							\
+		prepare_to_wait_exclusive(&wq, &__wait, TASK_KILLABLE);	\
+		if (condition)						\
+			break;						\
+		if (!fatal_signal_pending(current)) {			\
+			schedule();					\
+			continue;					\
+		}							\
+		ret = -ERESTARTSYS;					\
+		break;							\
+	}								\
+	finish_wait(&wq, &__wait);					\
+} while (0)
+
+
+#define wait_event_killable_exclusive(wq, condition)			\
+({									\
+	int __ret = 0;							\
+	if (!(condition))						\
+		__wait_event_killable_exclusive(wq, condition, __ret);	\
+	__ret;								\
+})
 
 #define __wait_event_lock_irq(wq, condition, lock, cmd)			\
 do {									\