Skip to content

Instantly share code, notes, and snippets.

@thehajime
Last active August 29, 2015 14:24
Show Gist options
  • Save thehajime/65e58a101f0c50a04764 to your computer and use it in GitHub Desktop.
Save thehajime/65e58a101f0c50a04764 to your computer and use it in GitHub Desktop.
patch for waitqueue issue (libos-nuse/net-next-nuse#45)
diff --git a/arch/lib/sched.c b/arch/lib/sched.c
index 98a568a..3f59028 100644
--- a/arch/lib/sched.c
+++ b/arch/lib/sched.c
@@ -164,17 +164,35 @@ void finish_wait(wait_queue_head_t *q, wait_queue_t *wait)
if (!list_empty(&wait->task_list))
list_del_init(&wait->task_list);
}
+#if 1
int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync,
void *key)
{
- int ret = default_wake_function(wait, mode, sync, key);
+ int ret;
+
+ ret = default_wake_function(wait, mode, sync, key);
if (ret && (wait->task_list.prev != LIST_POISON2))
list_del_init(&wait->task_list);
return ret;
}
+#else
+int autoremove_wake_function(wait_queue_t *wait, unsigned mode, int sync,
+ void *key)
+{
+ wait_queue_t copy_wait;
+ int ret;
+ memcpy(&copy_wait, wait, sizeof(wait_queue_t));
+ ret = default_wake_function(&copy_wait, mode, sync, key);
+
+ if (ret && (copy_wait.task_list.prev != LIST_POISON2))
+ list_del_init(&copy_wait.task_list);
+
+ return ret;
+}
+#endif
int woken_wake_function(wait_queue_t *wait, unsigned mode, int sync, void *key)
{
wait->flags |= WQ_FLAG_WOKEN;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment