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/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)