MEDIUM: stream-int: split the shutr/shutw functions between applet and conn
These functions induce a lot of ifs everywhere because they consider two
different cases, one which is where the connection exists and has a file
descriptor, and the other one which is the default case where at most an
applet has to be notified.
Let's have them in si_ops and automatically decide which one to use.
The connection shutdown sequence has been slightly simplified, and we
now clear the flags at the end.
Also we remove SHUTR_NOW after a shutw with nolinger, as it's cleaner
not to keep it.
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index c43ef57..f01048c 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -36,8 +36,6 @@
void stream_int_report_error(struct stream_interface *si);
void stream_int_retnclose(struct stream_interface *si, const struct chunk *msg);
int conn_si_send_proxy(struct connection *conn, unsigned int flag);
-int stream_int_shutr(struct stream_interface *si);
-int stream_int_shutw(struct stream_interface *si);
void stream_sock_read0(struct stream_interface *si);
extern struct si_ops si_embedded_ops;
@@ -74,14 +72,14 @@
/* Sends a shutr to the connection using the data layer */
static inline void si_shutr(struct stream_interface *si)
{
- if (stream_int_shutr(si))
+ if (si->ops->shutr(si))
conn_data_stop_recv(si->conn);
}
/* Sends a shutw to the connection using the data layer */
static inline void si_shutw(struct stream_interface *si)
{
- if (stream_int_shutw(si))
+ if (si->ops->shutw(si))
conn_data_stop_send(si->conn);
}
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 6748fbf..257a5d6 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -85,6 +85,8 @@
void (*update)(struct stream_interface *); /* I/O update function */
void (*chk_rcv)(struct stream_interface *); /* chk_rcv function */
void (*chk_snd)(struct stream_interface *); /* chk_snd function */
+ int (*shutr)(struct stream_interface *); /* shut read function */
+ int (*shutw)(struct stream_interface *); /* shut write function */
};
/* A stream interface has 3 parts :