Since
09d69eacf8 ("MEDIUM: sink: start applets asynchronously") the applet
is no longer initialized under the sft lock while it was the case before.
At first it doesn't seem to be an issue, but if we look closer at
sink_forward_session_init(), we can see that sft->appctx is assigned
while it can be accessed at the same time from sink_init_forward().
Let's restore the old guarantees by performing the .init under the sft
lock.
No backport needed unless
09d69eacf8 is.
struct stream *s;
struct sockaddr_storage *addr = NULL;
+ /* sft init is performed asynchronously so <sft> must be manipulated
+ * under the lock
+ */
+ HA_SPIN_LOCK(SFT_LOCK, &sft->lock);
+
if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr)))
goto out_error;
/* srv port should be learned from srv->svc_port not from srv->addr */
applet_expect_no_data(appctx);
sft->appctx = appctx;
+ HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
+
return 0;
out_free_addr:
sockaddr_free(&addr);
out_error:
+ HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
return -1;
}