CLEANUP: connection: rename subscription events values and event field

The SUB_CAN_SEND/SUB_CAN_RECV enum values have been confusing a few
times, especially when checking them on reading. After some discussion,
it appears that calling them SUB_RETRY_SEND/SUB_RETRY_RECV more
accurately reflects their purpose since these events may only appear
after a first attempt to perform the I/O operation has failed or was
not completed.

In addition the wait_reason field in struct wait_event which carries
them makes one think that a single reason may happen at once while
it is in fact a set of events. Since the struct is called wait_event
it makes sense that this field is called "events" to indicate it's the
list of events we're subscribed to.

Last, the values for SUB_RETRY_RECV/SEND were swapped so that value
1 corresponds to recv and 2 to send, as is done almost everywhere else
in the code an in the shutdown() call.
diff --git a/src/checks.c b/src/checks.c
index e4bb732..cb89f2f 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -712,9 +712,9 @@
 	struct check *check = ctx;
 	struct conn_stream *cs = check->cs;
 
-	if (!(check->wait_list.wait_reason & SUB_CAN_SEND))
+	if (!(check->wait_list.events & SUB_RETRY_SEND))
 		wake_srv_chk(cs);
-	if (!(check->wait_list.wait_reason & SUB_CAN_RECV)) {
+	if (!(check->wait_list.events & SUB_RETRY_RECV)) {
 		HA_SPIN_LOCK(SERVER_LOCK, &check->server->lock);
 		__event_srv_chk_r(cs);
 		HA_SPIN_UNLOCK(SERVER_LOCK, &check->server->lock);
@@ -739,7 +739,7 @@
 		goto out_wakeup;
 
 	if (conn->flags & CO_FL_HANDSHAKE) {
-		cs->conn->mux->subscribe(cs, SUB_CAN_SEND, &check->wait_list);
+		cs->conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
 		goto out;
 	}
 
@@ -773,7 +773,7 @@
 			goto out_wakeup;
 		}
 		if (b_data(&check->bo)) {
-			conn->mux->subscribe(cs, SUB_CAN_SEND, &check->wait_list);
+			conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
 			goto out;
 		}
 	}
@@ -824,7 +824,7 @@
 		goto out_wakeup;
 
 	if (conn->flags & CO_FL_HANDSHAKE) {
-		cs->conn->mux->subscribe(cs, SUB_CAN_RECV, &check->wait_list);
+		cs->conn->mux->subscribe(cs, SUB_RETRY_RECV, &check->wait_list);
 		goto out;
 	}
 
@@ -1380,7 +1380,7 @@
 	return;
 
  wait_more_data:
-	cs->conn->mux->subscribe(cs, SUB_CAN_RECV, &check->wait_list);
+	cs->conn->mux->subscribe(cs, SUB_RETRY_RECV, &check->wait_list);
         goto out;
 }
 
@@ -1403,7 +1403,7 @@
 		ret = tcpcheck_main(check);
 		cs = check->cs;
 		conn = cs->conn;
-	} else if (!(check->wait_list.wait_reason & SUB_CAN_SEND))
+	} else if (!(check->wait_list.events & SUB_RETRY_SEND))
 		__event_srv_chk_w(cs);
 
 	if (unlikely(conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR)) {
@@ -1576,7 +1576,7 @@
 		return SF_ERR_RESOURCE;
 	conn = cs->conn;
 	/* Maybe there were an older connection we were waiting on */
-	check->wait_list.wait_reason = 0;
+	check->wait_list.events = 0;
 
 	if (is_addr(&check->addr)) {
 		/* we'll connect to the check addr specified on the server */
@@ -2693,7 +2693,7 @@
 				break;
 			}
 			if (b_data(&check->bo)) {
-				cs->conn->mux->subscribe(cs, SUB_CAN_SEND, &check->wait_list);
+				cs->conn->mux->subscribe(cs, SUB_RETRY_SEND, &check->wait_list);
 				goto out;
 			}
 		}
@@ -2755,7 +2755,7 @@
 			check->cs = cs;
 			conn = cs->conn;
 			/* Maybe there were an older connection we were waiting on */
-			check->wait_list.wait_reason = 0;
+			check->wait_list.events = 0;
 			conn->target = &s->obj_type;
 
 			/* no client address */
@@ -2919,7 +2919,7 @@
 					}
 				}
 				else {
-					conn->mux->subscribe(cs, SUB_CAN_RECV, &check->wait_list);
+					conn->mux->subscribe(cs, SUB_RETRY_RECV, &check->wait_list);
 					break;
 				}
 			}
@@ -3112,7 +3112,7 @@
 	check->wait_list.task = tasklet_new();
 	if (!check->wait_list.task)
 		return "out of memroy while allocating check tasklet";
-	check->wait_list.wait_reason = 0;
+	check->wait_list.events = 0;
 	check->wait_list.task->process = event_srv_chk_io;
 	check->wait_list.task->context = check;
 	return NULL;
diff --git a/src/connection.c b/src/connection.c
index 2b0063e..37e48c5 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -112,7 +112,7 @@
 		 */
 		flags = 0;
 		if (conn->send_wait != NULL) {
-			conn->send_wait->wait_reason &= ~SUB_CAN_SEND;
+			conn->send_wait->events &= ~SUB_RETRY_SEND;
 			tasklet_wakeup(conn->send_wait->task);
 			conn->send_wait = NULL;
 		} else
@@ -132,7 +132,7 @@
 		 */
 		flags = 0;
 		if (conn->recv_wait) {
-			conn->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+			conn->recv_wait->events &= ~SUB_RETRY_RECV;
 			tasklet_wakeup(conn->recv_wait->task);
 			conn->recv_wait = NULL;
 		} else
@@ -320,19 +320,19 @@
 {
 	struct wait_event *sw;
 
-	if (event_type & SUB_CAN_RECV) {
+	if (event_type & SUB_RETRY_RECV) {
 		sw = param;
-		if (sw->wait_reason & SUB_CAN_RECV) {
+		if (sw->events & SUB_RETRY_RECV) {
 			conn->recv_wait = NULL;
-			sw->wait_reason &= ~SUB_CAN_RECV;
+			sw->events &= ~SUB_RETRY_RECV;
 		}
 		__conn_xprt_stop_recv(conn);
 	}
-	if (event_type & SUB_CAN_SEND) {
+	if (event_type & SUB_RETRY_SEND) {
 		sw = param;
-		if (sw->wait_reason & SUB_CAN_SEND) {
+		if (sw->events & SUB_RETRY_SEND) {
 			conn->send_wait = NULL;
-			sw->wait_reason &= ~SUB_CAN_SEND;
+			sw->events &= ~SUB_RETRY_SEND;
 		}
 		__conn_xprt_stop_send(conn);
 	}
@@ -344,22 +344,22 @@
 {
 	struct wait_event *sw;
 
-	if (event_type & SUB_CAN_RECV) {
+	if (event_type & SUB_RETRY_RECV) {
 		sw = param;
-		if (!(sw->wait_reason & SUB_CAN_RECV)) {
-			sw->wait_reason |= SUB_CAN_RECV;
+		if (!(sw->events & SUB_RETRY_RECV)) {
+			sw->events |= SUB_RETRY_RECV;
 			conn->recv_wait = sw;
 		}
-		event_type &= ~SUB_CAN_RECV;
+		event_type &= ~SUB_RETRY_RECV;
 		__conn_xprt_want_recv(conn);
 	}
-	if (event_type & SUB_CAN_SEND) {
+	if (event_type & SUB_RETRY_SEND) {
 		sw = param;
-		if (!(sw->wait_reason & SUB_CAN_SEND)) {
-			sw->wait_reason |= SUB_CAN_SEND;
+		if (!(sw->events & SUB_RETRY_SEND)) {
+			sw->events |= SUB_RETRY_SEND;
 			conn->send_wait = sw;
 		}
-		event_type &= ~SUB_CAN_SEND;
+		event_type &= ~SUB_RETRY_SEND;
 		__conn_xprt_want_send(conn);
 	}
 	if (event_type != 0)
diff --git a/src/mux_h1.c b/src/mux_h1.c
index af2ce77..bca4773 100644
--- a/src/mux_h1.c
+++ b/src/mux_h1.c
@@ -321,9 +321,9 @@
 		h1c->h1s = NULL;
 
 		if (h1s->recv_wait != NULL)
-			h1s->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+			h1s->recv_wait->events &= ~SUB_RETRY_RECV;
 		if (h1s->send_wait != NULL)
-			h1s->send_wait->wait_reason &= ~SUB_CAN_SEND;
+			h1s->send_wait->events &= ~SUB_RETRY_SEND;
 
 		h1c->flags &= ~H1C_F_IN_BUSY;
 		h1c->flags |= H1C_F_WAIT_NEXT_REQ;
@@ -370,7 +370,7 @@
 		goto fail;
 	h1c->wait_event.task->process = h1_io_cb;
 	h1c->wait_event.task->context = h1c;
-	h1c->wait_event.wait_reason   = 0;
+	h1c->wait_event.events   = 0;
 
 	if (!(conn->flags & CO_FL_CONNECTED))
 		h1c->flags |= H1C_F_CS_WAIT_CONN;
@@ -421,8 +421,8 @@
 			tasklet_free(h1c->wait_event.task);
 
 		h1s_destroy(h1c->h1s);
-		if (h1c->wait_event.wait_reason != 0)
-			conn->xprt->unsubscribe(conn, h1c->wait_event.wait_reason,
+		if (h1c->wait_event.events != 0)
+			conn->xprt->unsubscribe(conn, h1c->wait_event.events,
 			    &h1c->wait_event);
 		pool_free(pool_head_h1c, h1c);
 	}
@@ -1624,7 +1624,7 @@
 static void h1_wake_stream_for_recv(struct h1s *h1s)
 {
 	if (h1s && h1s->recv_wait) {
-		h1s->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+		h1s->recv_wait->events &= ~SUB_RETRY_RECV;
 		tasklet_wakeup(h1s->recv_wait->task);
 		h1s->recv_wait = NULL;
 	}
@@ -1632,7 +1632,7 @@
 static void h1_wake_stream_for_send(struct h1s *h1s)
 {
 	if (h1s && h1s->send_wait) {
-		h1s->send_wait->wait_reason &= ~SUB_CAN_SEND;
+		h1s->send_wait->events &= ~SUB_RETRY_SEND;
 		tasklet_wakeup(h1s->send_wait->task);
 		h1s->send_wait = NULL;
 	}
@@ -1648,7 +1648,7 @@
 	size_t ret = 0, max;
 	int rcvd = 0;
 
-	if (h1c->wait_event.wait_reason & SUB_CAN_RECV)
+	if (h1c->wait_event.events & SUB_RETRY_RECV)
 		return (b_data(&h1c->ibuf));
 
 	if (!h1_recv_allowed(h1c)) {
@@ -1700,7 +1700,7 @@
 		goto end;
 	}
 
-	conn->xprt->subscribe(conn, SUB_CAN_RECV, &h1c->wait_event);
+	conn->xprt->subscribe(conn, SUB_RETRY_RECV, &h1c->wait_event);
 
   end:
 	if (ret > 0 || (conn->flags & CO_FL_ERROR) || conn_xprt_read0_pending(conn))
@@ -1730,8 +1730,8 @@
 		return 0;
 
 	if (h1c->flags & H1C_F_CS_WAIT_CONN) {
-		if (!(h1c->wait_event.wait_reason & SUB_CAN_SEND))
-			conn->xprt->subscribe(conn, SUB_CAN_SEND, &h1c->wait_event);
+		if (!(h1c->wait_event.events & SUB_RETRY_SEND))
+			conn->xprt->subscribe(conn, SUB_RETRY_SEND, &h1c->wait_event);
 		return 0;
 	}
 
@@ -1764,8 +1764,8 @@
 		if (h1c->flags & H1C_F_CS_SHUTW_NOW)
 			h1_shutw_conn(conn);
 	}
-	else if (!(h1c->wait_event.wait_reason & SUB_CAN_SEND))
-		conn->xprt->subscribe(conn, SUB_CAN_SEND, &h1c->wait_event);
+	else if (!(h1c->wait_event.events & SUB_RETRY_SEND))
+		conn->xprt->subscribe(conn, SUB_RETRY_SEND, &h1c->wait_event);
 
 	return sent;
 }
@@ -1832,9 +1832,9 @@
 	struct h1c *h1c = ctx;
 	int ret = 0;
 
-	if (!(h1c->wait_event.wait_reason & SUB_CAN_SEND))
+	if (!(h1c->wait_event.events & SUB_RETRY_SEND))
 		ret = h1_send(h1c);
-	if (!(h1c->wait_event.wait_reason & SUB_CAN_RECV))
+	if (!(h1c->wait_event.events & SUB_RETRY_RECV))
 		ret |= h1_recv(h1c);
 	if (ret || !h1c->h1s)
 		h1_process(h1c);
@@ -2052,17 +2052,17 @@
 	if (!h1s)
 		return 0;
 
-	if (event_type & SUB_CAN_RECV) {
+	if (event_type & SUB_RETRY_RECV) {
 		sw = param;
 		if (h1s->recv_wait == sw) {
-			sw->wait_reason &= ~SUB_CAN_RECV;
+			sw->events &= ~SUB_RETRY_RECV;
 			h1s->recv_wait = NULL;
 		}
 	}
-	if (event_type & SUB_CAN_SEND) {
+	if (event_type & SUB_RETRY_SEND) {
 		sw = param;
 		if (h1s->send_wait == sw) {
-			sw->wait_reason &= ~SUB_CAN_SEND;
+			sw->events &= ~SUB_RETRY_SEND;
 			h1s->send_wait = NULL;
 		}
 	}
@@ -2079,18 +2079,18 @@
 		return -1;
 
 	switch (event_type) {
-		case SUB_CAN_RECV:
+		case SUB_RETRY_RECV:
 			sw = param;
-			if (!(sw->wait_reason & SUB_CAN_RECV)) {
-				sw->wait_reason |= SUB_CAN_RECV;
+			if (!(sw->events & SUB_RETRY_RECV)) {
+				sw->events |= SUB_RETRY_RECV;
 				sw->handle = h1s;
 				h1s->recv_wait = sw;
 			}
 			return 0;
-		case SUB_CAN_SEND:
+		case SUB_RETRY_SEND:
 			sw = param;
-			if (!(sw->wait_reason & SUB_CAN_SEND)) {
-				sw->wait_reason |= SUB_CAN_SEND;
+			if (!(sw->events & SUB_RETRY_SEND)) {
+				sw->events |= SUB_RETRY_SEND;
 				sw->handle = h1s;
 				h1s->send_wait = sw;
 			}
@@ -2115,7 +2115,7 @@
 		h1s->flags |= H1S_F_BUF_FLUSH;
 	else if (ret > 0 || (h1s->flags & H1S_F_SPLICED_DATA)) {
 		h1s->flags &= ~H1S_F_SPLICED_DATA;
-		if (!(h1c->wait_event.wait_reason & SUB_CAN_RECV))
+		if (!(h1c->wait_event.events & SUB_RETRY_RECV))
 			tasklet_wakeup(h1c->wait_event.task);
 	}
 	return ret;
@@ -2187,8 +2187,8 @@
 	ret = cs->conn->xprt->snd_pipe(cs->conn, pipe);
   end:
 	if (pipe->data) {
-		if (!(h1s->h1c->wait_event.wait_reason & SUB_CAN_SEND))
-			cs->conn->xprt->subscribe(cs->conn, SUB_CAN_SEND, &h1s->h1c->wait_event);
+		if (!(h1s->h1c->wait_event.events & SUB_RETRY_SEND))
+			cs->conn->xprt->subscribe(cs->conn, SUB_RETRY_SEND, &h1s->h1c->wait_event);
 	}
 	return ret;
 }
diff --git a/src/mux_h2.c b/src/mux_h2.c
index 862c188..499e423 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -416,7 +416,7 @@
 		goto fail;
 	h2c->wait_event.task->process = h2_io_cb;
 	h2c->wait_event.task->context = h2c;
-	h2c->wait_event.wait_reason = 0;
+	h2c->wait_event.events = 0;
 
 	h2c->ddht = hpack_dht_alloc(h2_settings_header_table_size);
 	if (!h2c->ddht)
@@ -535,8 +535,8 @@
 		}
 		if (h2c->wait_event.task)
 			tasklet_free(h2c->wait_event.task);
-		if (h2c->wait_event.wait_reason != 0)
-			conn->xprt->unsubscribe(conn, h2c->wait_event.wait_reason,
+		if (h2c->wait_event.events != 0)
+			conn->xprt->unsubscribe(conn, h2c->wait_event.events,
 			    &h2c->wait_event);
 
 		pool_free(pool_head_h2c, h2c);
@@ -703,9 +703,9 @@
 		offer_buffers(NULL, tasks_run_queue);
 	}
 	if (h2s->send_wait != NULL)
-		h2s->send_wait->wait_reason &= ~SUB_CAN_SEND;
+		h2s->send_wait->events &= ~SUB_RETRY_SEND;
 	if (h2s->recv_wait != NULL)
-		h2s->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+		h2s->recv_wait->events &= ~SUB_RETRY_RECV;
 	/* There's no need to explicitly call unsubscribe here, the only
 	 * reference left would be in the h2c send_list/fctl_list, and if
 	 * we're in it, we're getting out anyway
@@ -740,7 +740,7 @@
 	h2s->wait_event.task->process = h2_deferred_shut;
 	h2s->wait_event.task->context = h2s;
 	h2s->wait_event.handle = NULL;
-	h2s->wait_event.wait_reason = 0;
+	h2s->wait_event.events = 0;
 	LIST_INIT(&h2s->list);
 	h2s->h2c       = h2c;
 	h2s->cs        = NULL;
@@ -1265,7 +1265,7 @@
 
 		if (h2s->recv_wait) {
 			struct wait_event *sw = h2s->recv_wait;
-			sw->wait_reason &= ~SUB_CAN_RECV;
+			sw->events &= ~SUB_RETRY_RECV;
 			tasklet_wakeup(sw->task);
 			h2s->recv_wait = NULL;
 		} else if (h2s->cs->data_cb->wake != NULL)
@@ -1750,7 +1750,7 @@
 		if (h2s->recv_wait) {
 			struct wait_event *sw = h2s->recv_wait;
 
-			sw->wait_reason &= ~SUB_CAN_RECV;
+			sw->events &= ~SUB_RETRY_RECV;
 			tasklet_wakeup(sw->task);
 			h2s->recv_wait = NULL;
 		}
@@ -2106,7 +2106,7 @@
 			/* we may have to signal the upper layers */
 			h2s->cs->flags |= CS_FL_RCV_MORE;
 			if (h2s->recv_wait) {
-				h2s->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+				h2s->recv_wait->events &= ~SUB_RETRY_RECV;
 				tasklet_wakeup(h2s->recv_wait->task);
 				h2s->recv_wait = NULL;
 			}
@@ -2346,7 +2346,7 @@
 		/* we may have to signal the upper layers */
 		h2s->cs->flags |= CS_FL_RCV_MORE;
 		if (h2s->recv_wait) {
-			h2s->recv_wait->wait_reason &= ~SUB_CAN_RECV;
+			h2s->recv_wait->events &= ~SUB_RETRY_RECV;
 			tasklet_wakeup(h2s->recv_wait->task);
 			h2s->recv_wait = NULL;
 		}
@@ -2397,8 +2397,8 @@
 			break;
 
 		h2s->flags &= ~H2_SF_BLK_ANY;
-		h2s->send_wait->wait_reason &= ~SUB_CAN_SEND;
-		h2s->send_wait->wait_reason |= SUB_CALL_UNSUBSCRIBE;
+		h2s->send_wait->events &= ~SUB_RETRY_SEND;
+		h2s->send_wait->events |= SUB_CALL_UNSUBSCRIBE;
 		tasklet_wakeup(h2s->send_wait->task);
 		LIST_DEL(&h2s->list);
 		LIST_INIT(&h2s->list);
@@ -2410,8 +2410,8 @@
 			break;
 
 		h2s->flags &= ~H2_SF_BLK_ANY;
-		h2s->send_wait->wait_reason &= ~SUB_CAN_SEND;
-		h2s->send_wait->wait_reason |= SUB_CALL_UNSUBSCRIBE;
+		h2s->send_wait->events &= ~SUB_RETRY_SEND;
+		h2s->send_wait->events |= SUB_CALL_UNSUBSCRIBE;
 		tasklet_wakeup(h2s->send_wait->task);
 		LIST_DEL(&h2s->list);
 		LIST_INIT(&h2s->list);
@@ -2445,7 +2445,7 @@
 	int max;
 	size_t ret;
 
-	if (h2c->wait_event.wait_reason & SUB_CAN_RECV)
+	if (h2c->wait_event.events & SUB_RETRY_RECV)
 		return (b_data(&h2c->dbuf));
 
 	if (!h2_recv_allowed(h2c))
@@ -2481,7 +2481,7 @@
 	} while (ret > 0);
 
 	if (h2_recv_allowed(h2c) && (b_data(buf) < buf->size))
-		conn->xprt->subscribe(conn, SUB_CAN_RECV, &h2c->wait_event);
+		conn->xprt->subscribe(conn, SUB_RETRY_RECV, &h2c->wait_event);
 
 	if (!b_data(buf)) {
 		h2_release_buf(h2c, &h2c->dbuf);
@@ -2571,8 +2571,8 @@
 			LIST_DEL(&h2s->list);
 			LIST_INIT(&h2s->list);
 			LIST_ADDQ(&h2c->sending_list, &h2s->list);
-			h2s->send_wait->wait_reason &= ~SUB_CAN_SEND;
-			h2s->send_wait->wait_reason |= SUB_CALL_UNSUBSCRIBE;
+			h2s->send_wait->events &= ~SUB_RETRY_SEND;
+			h2s->send_wait->events |= SUB_CALL_UNSUBSCRIBE;
 			tasklet_wakeup(h2s->send_wait->task);
 		}
 	}
@@ -2580,8 +2580,8 @@
 	if (!b_data(&h2c->mbuf))
 		return sent;
 schedule:
-	if (!(h2c->wait_event.wait_reason & SUB_CAN_SEND))
-		conn->xprt->subscribe(conn, SUB_CAN_SEND, &h2c->wait_event);
+	if (!(h2c->wait_event.events & SUB_RETRY_SEND))
+		conn->xprt->subscribe(conn, SUB_RETRY_SEND, &h2c->wait_event);
 	return sent;
 }
 
@@ -2590,9 +2590,9 @@
 	struct h2c *h2c = ctx;
 	int ret = 0;
 
-	if (!(h2c->wait_event.wait_reason & SUB_CAN_SEND))
+	if (!(h2c->wait_event.events & SUB_RETRY_SEND))
 		ret = h2_send(h2c);
-	if (!(h2c->wait_event.wait_reason & SUB_CAN_RECV))
+	if (!(h2c->wait_event.events & SUB_RETRY_RECV))
 		ret |= h2_recv(h2c);
 	if (ret || b_data(&h2c->dbuf))
 		h2_process(h2c);
@@ -2647,7 +2647,7 @@
 			if ((h2s->cs->flags & CS_FL_WAIT_FOR_HS) &&
 			    h2s->recv_wait) {
 				struct wait_event *sw = h2s->recv_wait;
-				sw->wait_reason &= ~SUB_CAN_RECV;
+				sw->events &= ~SUB_RETRY_RECV;
 				tasklet_wakeup(sw->task);
 				h2s->recv_wait = NULL;
 			}
@@ -2932,14 +2932,14 @@
 	    h2c_send_goaway_error(h2c, h2s) <= 0)
 		return;
 
-	if (!(h2c->wait_event.wait_reason & SUB_CAN_SEND))
+	if (!(h2c->wait_event.events & SUB_RETRY_SEND))
 		tasklet_wakeup(h2c->wait_event.task);
 	h2s_close(h2s);
 
 	return;
 add_to_list:
 	if (LIST_ISEMPTY(&h2s->list)) {
-		sw->wait_reason |= SUB_CAN_SEND;
+		sw->events |= SUB_RETRY_SEND;
 		if (h2s->flags & H2_SF_BLK_MFCTL) {
 			LIST_ADDQ(&h2c->fctl_list, &h2s->list);
 			h2s->send_wait = sw;
@@ -2990,13 +2990,13 @@
 		h2s_close(h2s);
 	}
 
-	if (!(h2c->wait_event.wait_reason & SUB_CAN_SEND))
+	if (!(h2c->wait_event.events & SUB_RETRY_SEND))
 		tasklet_wakeup(h2c->wait_event.task);
 	return;
 
  add_to_list:
 	if (LIST_ISEMPTY(&h2s->list)) {
-		sw->wait_reason |= SUB_CAN_SEND;
+		sw->events |= SUB_RETRY_SEND;
 		if (h2s->flags & H2_SF_BLK_MFCTL) {
 			LIST_ADDQ(&h2c->fctl_list, &h2s->list);
 			h2s->send_wait = sw;
@@ -3016,7 +3016,7 @@
 	long reason = (long)h2s->wait_event.handle;
 
 	if (h2s->send_wait) {
-		h2s->send_wait->wait_reason &= ~SUB_CALL_UNSUBSCRIBE;
+		h2s->send_wait->events &= ~SUB_CALL_UNSUBSCRIBE;
 		h2s->send_wait = NULL;
 		LIST_DEL(&h2s->list);
 		LIST_INIT(&h2s->list);
@@ -4526,19 +4526,19 @@
 	struct h2s *h2s = cs->ctx;
 	struct h2c *h2c = h2s->h2c;
 
-	if (event_type & SUB_CAN_RECV) {
+	if (event_type & SUB_RETRY_RECV) {
 		sw = param;
-		if (!(sw->wait_reason & SUB_CAN_RECV)) {
-			sw->wait_reason |= SUB_CAN_RECV;
+		if (!(sw->events & SUB_RETRY_RECV)) {
+			sw->events |= SUB_RETRY_RECV;
 			sw->handle = h2s;
 			h2s->recv_wait = sw;
 		}
-		event_type &= ~SUB_CAN_RECV;
+		event_type &= ~SUB_RETRY_RECV;
 	}
-	if (event_type & SUB_CAN_SEND) {
+	if (event_type & SUB_RETRY_SEND) {
 		sw = param;
-		if (!(sw->wait_reason & SUB_CAN_SEND)) {
-			sw->wait_reason |= SUB_CAN_SEND;
+		if (!(sw->events & SUB_RETRY_SEND)) {
+			sw->events |= SUB_RETRY_SEND;
 			sw->handle = h2s;
 			h2s->send_wait = sw;
 			if (!(h2s->flags & H2_SF_BLK_SFCTL)) {
@@ -4548,7 +4548,7 @@
 					LIST_ADDQ(&h2c->send_list, &h2s->list);
 			}
 		}
-		event_type &= ~SUB_CAN_SEND;
+		event_type &= ~SUB_RETRY_SEND;
 	}
 	if (event_type != 0)
 		return -1;
@@ -4562,26 +4562,26 @@
 	struct wait_event *sw;
 	struct h2s *h2s = cs->ctx;
 
-	if (event_type & SUB_CAN_RECV) {
+	if (event_type & SUB_RETRY_RECV) {
 		sw = param;
 		if (h2s->recv_wait == sw) {
-			sw->wait_reason &= ~SUB_CAN_RECV;
+			sw->events &= ~SUB_RETRY_RECV;
 			h2s->recv_wait = NULL;
 		}
 	}
-	if (event_type & SUB_CAN_SEND) {
+	if (event_type & SUB_RETRY_SEND) {
 		sw = param;
 		if (h2s->send_wait == sw) {
 			LIST_DEL(&h2s->list);
 			LIST_INIT(&h2s->list);
-			sw->wait_reason &= ~SUB_CAN_SEND;
+			sw->events &= ~SUB_RETRY_SEND;
 			h2s->send_wait = NULL;
 		}
 	}
 	if (event_type & SUB_CALL_UNSUBSCRIBE) {
 		sw = param;
 		if (h2s->send_wait == sw) {
-			sw->wait_reason &= ~SUB_CALL_UNSUBSCRIBE;
+			sw->events &= ~SUB_CALL_UNSUBSCRIBE;
 			h2s->send_wait = NULL;
 		}
 	}
@@ -4642,7 +4642,7 @@
 	if (ret && h2c->dsi == h2s->id) {
 		/* demux is blocking on this stream's buffer */
 		h2c->flags &= ~H2_CF_DEM_SFULL;
-		if (b_data(&h2c->dbuf) || !(h2c->wait_event.wait_reason & SUB_CAN_RECV)) {
+		if (b_data(&h2c->dbuf) || !(h2c->wait_event.events & SUB_RETRY_RECV)) {
 			if (h2_recv_allowed(h2c))
 				tasklet_wakeup(h2c->wait_event.task);
 		}
@@ -4662,8 +4662,8 @@
 		LIST_DEL(&h2s->list);
 		LIST_INIT(&h2s->list);
 		task_remove_from_task_list((struct task *)h2s->send_wait->task);
-		h2s->send_wait->wait_reason |= SUB_CAN_SEND;
-		h2s->send_wait->wait_reason &= ~SUB_CALL_UNSUBSCRIBE;
+		h2s->send_wait->events |= SUB_RETRY_SEND;
+		h2s->send_wait->events &= ~SUB_CALL_UNSUBSCRIBE;
 		LIST_ADD(&h2c->send_list, &h2s->list);
 	}
 }
@@ -4682,7 +4682,7 @@
 	int32_t idx;
 
 	if (h2s->send_wait) {
-		h2s->send_wait->wait_reason &= ~SUB_CALL_UNSUBSCRIBE;
+		h2s->send_wait->events &= ~SUB_CALL_UNSUBSCRIBE;
 		h2s->send_wait = NULL;
 		LIST_DEL(&h2s->list);
 		LIST_INIT(&h2s->list);
@@ -4844,7 +4844,7 @@
 		total = orig_count;
 
 	if (total > 0) {
-		if (!(h2s->h2c->wait_event.wait_reason & SUB_CAN_SEND))
+		if (!(h2s->h2c->wait_event.events & SUB_RETRY_SEND))
 			tasklet_wakeup(h2s->h2c->wait_event.task);
 
 	}
@@ -4886,7 +4886,7 @@
 		      " .orph_cnt=%d .sub=%d .dsi=%d .dbuf=%u@%p+%u/%u .msi=%d .mbuf=%u@%p+%u/%u",
 		      h2c->st0, h2c->errcode, h2c->max_id, h2c->last_sid, h2c->flags,
 		      h2c->nb_streams, h2c->nb_cs, fctl_cnt, send_cnt, tree_cnt, orph_cnt,
-		      h2c->wait_event.wait_reason, h2c->dsi,
+		      h2c->wait_event.events, h2c->dsi,
 		      (unsigned int)b_data(&h2c->dbuf), b_orig(&h2c->dbuf),
 		      (unsigned int)b_head_ofs(&h2c->dbuf), (unsigned int)b_size(&h2c->dbuf),
 		      h2c->msi,
diff --git a/src/mux_pt.c b/src/mux_pt.c
index 4d3303a..43c3f6f 100644
--- a/src/mux_pt.c
+++ b/src/mux_pt.c
@@ -52,7 +52,7 @@
 	if (ctx->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))
 		mux_pt_destroy(ctx);
 	else
-		ctx->conn->xprt->subscribe(ctx->conn, SUB_CAN_RECV,
+		ctx->conn->xprt->subscribe(ctx->conn, SUB_RETRY_RECV,
 		    &ctx->wait_event);
 
 	return NULL;
@@ -76,7 +76,7 @@
 		goto fail_free_ctx;
 	ctx->wait_event.task->context = ctx;
 	ctx->wait_event.task->process = mux_pt_io_cb;
-	ctx->wait_event.wait_reason = 0;
+	ctx->wait_event.events = 0;
 	ctx->conn = conn;
 
 	if (!cs) {
@@ -143,7 +143,7 @@
 	struct conn_stream *cs;
 	struct mux_pt_ctx *ctx = conn->mux_ctx;
 
-	conn->xprt->unsubscribe(conn, SUB_CAN_RECV, &ctx->wait_event);
+	conn->xprt->unsubscribe(conn, SUB_RETRY_RECV, &ctx->wait_event);
 	cs = cs_new(conn);
 	if (!cs)
 		goto fail;
@@ -187,7 +187,7 @@
 	if (conn->owner != NULL &&
 	    !(conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) {
 		ctx->cs = NULL;
-		conn->xprt->subscribe(conn, SUB_CAN_RECV, &ctx->wait_event);
+		conn->xprt->subscribe(conn, SUB_RETRY_RECV, &ctx->wait_event);
 	} else
 		/* There's no session attached to that connection, destroy it */
 		mux_pt_destroy(ctx);
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 5283ed5..53d030d 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -545,7 +545,7 @@
 	struct channel *oc = si_oc(si);
 
 	/* If we have data to send, try it now */
-	if (!channel_is_empty(oc) && !(si->wait_event.wait_reason & SUB_CAN_SEND))
+	if (!channel_is_empty(oc) && !(si->wait_event.events & SUB_RETRY_SEND))
 		si_cs_send(cs);
 
 	/* First step, report to the stream-int what was detected at the
@@ -596,7 +596,7 @@
 	int did_send = 0;
 
 	/* We're already waiting to be able to send, give up */
-	if (si->wait_event.wait_reason & SUB_CAN_SEND)
+	if (si->wait_event.events & SUB_RETRY_SEND)
 		return 0;
 
 	if (conn->flags & CO_FL_ERROR || cs->flags & CS_FL_ERROR)
@@ -680,7 +680,7 @@
  end:
 	/* We couldn't send all of our data, let the mux know we'd like to send more */
 	if (!channel_is_empty(oc))
-		conn->mux->subscribe(cs, SUB_CAN_SEND, &si->wait_event);
+		conn->mux->subscribe(cs, SUB_RETRY_SEND, &si->wait_event);
 	return did_send;
 }
 
@@ -698,9 +698,9 @@
 	if (!cs)
 		return NULL;
 
-	if (!(si->wait_event.wait_reason & SUB_CAN_SEND) && !channel_is_empty(si_oc(si)))
+	if (!(si->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(si_oc(si)))
 		ret = si_cs_send(cs);
-	if (!(si->wait_event.wait_reason & SUB_CAN_RECV))
+	if (!(si->wait_event.events & SUB_RETRY_RECV))
 		ret |= si_cs_recv(cs);
 	if (ret != 0)
 		si_cs_process(cs);
@@ -1004,7 +1004,7 @@
 	    !(si->flags & SI_FL_WAIT_DATA))       /* not waiting for data */
 		return;
 
-	if (!(si->wait_event.wait_reason & SUB_CAN_SEND) && !channel_is_empty(si_oc(si)))
+	if (!(si->wait_event.events & SUB_RETRY_SEND) && !channel_is_empty(si_oc(si)))
 		si_cs_send(cs);
 
 	if (cs->flags & CS_FL_ERROR || cs->conn->flags & CO_FL_ERROR) {
@@ -1093,7 +1093,7 @@
 	/* If another call to si_cs_recv() failed, and we subscribed to
 	 * recv events already, give up now.
 	 */
-	if (si->wait_event.wait_reason & SUB_CAN_RECV)
+	if (si->wait_event.events & SUB_RETRY_RECV)
 		return 0;
 
 	/* maybe we were called immediately after an asynchronous shutr */
@@ -1335,7 +1335,7 @@
 
 	/* Subscribe to receive events if we're blocking on I/O */
 	if (!si_rx_blocked(si)) {
-		conn->mux->subscribe(cs, SUB_CAN_RECV, &si->wait_event);
+		conn->mux->subscribe(cs, SUB_RETRY_RECV, &si->wait_event);
 		si_rx_endp_done(si);
 	} else {
 		si_rx_endp_more(si);