From 1615402a2116129c472ae13a00024b6f2671c6c8 Mon Sep 17 00:00:00 2001
From: Thierry FOURNIER <thierry.fournier@ozon.io>
Date: Sat, 9 Dec 2017 01:32:57 +0100
Subject: [PATCH] BUGFIX

---
 include/proto/task.h | 17 +++++++++++++++++
 src/hlua.c           |  1 +
 2 files changed, 18 insertions(+)

diff --git a/include/proto/task.h b/include/proto/task.h
index 4291482..a8a4026 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -323,6 +323,23 @@ static inline void notification_purge(struct list *purge)
 	}
 }
 
+static inline void notification_gc(struct list *purge)
+{
+	struct notification *com, *back;
+
+	/* Delete all pending communication signals. */
+	list_for_each_entry_safe(com, back, purge, purge_me) {
+		HA_SPIN_LOCK(NOTIF_LOCK, &com->lock);
+		if (com->task) {
+			HA_SPIN_UNLOCK(NOTIF_LOCK, &com->lock);
+			continue;
+		}
+		LIST_DEL(&com->purge_me);
+		HA_SPIN_UNLOCK(NOTIF_LOCK, &com->lock);
+		pool_free(pool_head_notification, com);
+	}
+}
+
 /* This function sends signals. It wakes all the tasks attached
  * to a list head, and remove the signal, and free the used
  * memory.
diff --git a/src/hlua.c b/src/hlua.c
index 2011c93..2c28e67 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -5510,6 +5510,7 @@ static struct task *hlua_process_task(struct task *task)
 		break;
 
 	case HLUA_E_AGAIN: /* co process or timeout wake me later. */
+		notification_gc(&hlua->com);
 		if (hlua->wake_time != TICK_ETERNITY)
 			task->expire = hlua->wake_time;
 		break;
-- 
2.9.5

