mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 00:27:08 +02:00
BUG/MEDIUM: sink: properly init applet under sft lock
Since09d69eacf8
("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 unless09d69eacf8
is.
This commit is contained in:
parent
06547dcf52
commit
c81b8ee480
@ -495,6 +495,11 @@ static int sink_forward_session_init(struct appctx *appctx)
|
|||||||
struct stream *s;
|
struct stream *s;
|
||||||
struct sockaddr_storage *addr = NULL;
|
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)))
|
if (!sockaddr_alloc(&addr, &sft->srv->addr, sizeof(sft->srv->addr)))
|
||||||
goto out_error;
|
goto out_error;
|
||||||
/* srv port should be learned from srv->svc_port not from srv->addr */
|
/* srv port should be learned from srv->svc_port not from srv->addr */
|
||||||
@ -516,11 +521,14 @@ static int sink_forward_session_init(struct appctx *appctx)
|
|||||||
applet_expect_no_data(appctx);
|
applet_expect_no_data(appctx);
|
||||||
sft->appctx = appctx;
|
sft->appctx = appctx;
|
||||||
|
|
||||||
|
HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out_free_addr:
|
out_free_addr:
|
||||||
sockaddr_free(&addr);
|
sockaddr_free(&addr);
|
||||||
out_error:
|
out_error:
|
||||||
|
HA_SPIN_UNLOCK(SFT_LOCK, &sft->lock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user