From 7365dad40f977a1535a2cea3963a3b1098da813a Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 20 Apr 2015 01:03:17 +0200 Subject: [PATCH] BUG/MEDIUM: stream-int: always reset si->ops when si->end is nullified It happened after changing the stream interface deinitialization sequence that we got random crashes with si_shutw() being called on NULL si->end. The reason was that si->ops was not reset after a call to si_release_endpoint() which is sometimes called directly. Thus we now move the resetting of si->ops just after any si->end assignment. It happens that si_detach() is now just the same as si_release_endpoint() and stream_int_unregister_handler(). Some cleanup will have to be performed there. It's not sure whether this problem can impact 1.5 since in 1.5 applets are part of the default embedded stream handler. The only way it could cause some trouble is if it's used with a connection, which doesn't seem possible at first glance. --- include/proto/stream_interface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 5d0b254f6..39a4f9ef5 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -150,6 +150,7 @@ static inline void si_reset(struct stream_interface *si) si->flags &= SI_FL_ISBACK; si->end = NULL; si->state = si->prev_state = SI_ST_INI; + si->ops = &si_embedded_ops; } /* sets the current and previous state of a stream interface to . This @@ -182,12 +183,12 @@ static inline void si_release_endpoint(struct stream_interface *si) appctx_free(appctx); /* we share the connection pool */ } si->end = NULL; + si->ops = &si_embedded_ops; } static inline void si_detach(struct stream_interface *si) { si_release_endpoint(si); - si->ops = &si_embedded_ops; } /* Turn a possibly existing connection endpoint of stream interface to