MEDIUM: connection: make use of the owner instead of container_of
This way the connection can become independant on the stream interface.
diff --git a/src/session.c b/src/session.c
index be25ccf..91684ad 100644
--- a/src/session.c
+++ b/src/session.c
@@ -260,7 +260,7 @@
*/
int conn_session_complete(struct connection *conn, int flag)
{
- struct session *s = container_of(conn, struct session, si[0].conn);
+ struct session *s = container_of(conn->owner, struct session, si[0]);
if (!(conn->flags & CO_FL_ERROR) && (session_complete(s) > 0)) {
conn->flags &= ~flag;
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 8037fb7..78c061c 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -485,7 +485,7 @@
*/
int conn_si_send_proxy(struct connection *conn, unsigned int flag)
{
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct stream_interface *si = conn->owner;
/* we might have been called just after an asynchronous shutw */
if (conn->flags & CO_FL_SOCK_WR_SH)
@@ -561,7 +561,7 @@
*/
void conn_notify_si(struct connection *conn)
{
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct stream_interface *si = conn->owner;
DPRINTF(stderr, "%s: si=%p, si->state=%d ib->flags=%08x ob->flags=%08x\n",
__FUNCTION__,
@@ -665,7 +665,7 @@
*/
static int si_conn_send_loop(struct connection *conn)
{
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct stream_interface *si = conn->owner;
struct channel *b = si->ob;
int write_poll = MAX_WRITE_POLL_LOOPS;
int ret;
@@ -940,7 +940,7 @@
*/
void si_conn_recv_cb(struct connection *conn)
{
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct stream_interface *si = conn->owner;
struct channel *b = si->ib;
int ret, max, cur_read;
int read_poll = MAX_READ_POLL_LOOPS;
@@ -1154,7 +1154,7 @@
*/
void si_conn_send_cb(struct connection *conn)
{
- struct stream_interface *si = container_of(conn, struct stream_interface, conn);
+ struct stream_interface *si = conn->owner;
struct channel *b = si->ob;
if (conn->flags & CO_FL_ERROR)