mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: stconn: Use a dedicated function to get the opposite sedesc
se_opposite() function is added to let an endpoint retrieve the opposite endpoint descriptor. Muxes supportng the zero-copy forwarding can now use it. The se_shutdown() function too. This will be use by the SPOP multiplexer to be able to retrieve the SPOE agent configuration attached to the applet on client side. The related issue is #2502.
This commit is contained in:
parent
4b8098bf48
commit
51ebf644e5
@ -27,6 +27,7 @@
|
||||
#include <haproxy/htx-t.h>
|
||||
#include <haproxy/obj_type.h>
|
||||
#include <haproxy/stconn-t.h>
|
||||
#include <haproxy/xref.h>
|
||||
|
||||
struct buffer;
|
||||
struct session;
|
||||
@ -134,6 +135,19 @@ static inline size_t se_ff_data(struct sedesc *se)
|
||||
return (se->iobuf.data + (se->iobuf.pipe ? se->iobuf.pipe->data : 0));
|
||||
}
|
||||
|
||||
|
||||
static inline struct sedesc *se_opposite(struct sedesc *se)
|
||||
{
|
||||
struct xref *peer = xref_get_peer_and_lock(&se->xref);
|
||||
struct sedesc *seo = NULL;;
|
||||
|
||||
if (peer) {
|
||||
seo = container_of(peer, struct sedesc, xref);
|
||||
xref_unlock(&se->xref, peer);
|
||||
}
|
||||
return seo;
|
||||
}
|
||||
|
||||
/* stream connector version */
|
||||
static forceinline void sc_ep_zero(struct stconn *sc)
|
||||
{
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include <haproxy/task.h>
|
||||
#include <haproxy/trace.h>
|
||||
#include <haproxy/vecpair.h>
|
||||
#include <haproxy/xref.h>
|
||||
|
||||
unsigned int nb_applets = 0;
|
||||
|
||||
@ -646,7 +645,6 @@ size_t appctx_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, unsig
|
||||
int appctx_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
|
||||
{
|
||||
struct appctx *appctx = __sc_appctx(sc);
|
||||
struct xref *peer;
|
||||
struct sedesc *sdo = NULL;
|
||||
unsigned int len, nego_flags = NEGO_FF_FL_NONE;
|
||||
int ret = 0;
|
||||
@ -661,13 +659,11 @@ int appctx_fastfwd(struct stconn *sc, unsigned int count, unsigned int flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
peer = xref_get_peer_and_lock(&appctx->sedesc->xref);
|
||||
if (!peer) {
|
||||
sdo = se_opposite(appctx->sedesc);
|
||||
if (!sdo) {
|
||||
TRACE_STATE("Opposite endpoint not available yet", APPLET_EV_RECV, appctx);
|
||||
goto end;
|
||||
}
|
||||
sdo = container_of(peer, struct sedesc, xref);
|
||||
xref_unlock(&appctx->sedesc->xref, peer);
|
||||
|
||||
if (appctx->to_forward && count > appctx->to_forward) {
|
||||
count = appctx->to_forward;
|
||||
|
12
src/mux_h1.c
12
src/mux_h1.c
@ -31,7 +31,6 @@
|
||||
#include <haproxy/stconn.h>
|
||||
#include <haproxy/stream.h>
|
||||
#include <haproxy/trace.h>
|
||||
#include <haproxy/xref.h>
|
||||
|
||||
/* H1 connection descriptor */
|
||||
struct h1c {
|
||||
@ -4603,16 +4602,7 @@ static size_t h1_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, in
|
||||
|
||||
static inline struct sedesc *h1s_opposite_sd(struct h1s *h1s)
|
||||
{
|
||||
struct xref *peer;
|
||||
struct sedesc *sdo;
|
||||
|
||||
peer = xref_get_peer_and_lock(&h1s->sd->xref);
|
||||
if (!peer)
|
||||
return NULL;
|
||||
|
||||
sdo = container_of(peer, struct sedesc, xref);
|
||||
xref_unlock(&h1s->sd->xref, peer);
|
||||
return sdo;
|
||||
return se_opposite(h1s->sd);
|
||||
}
|
||||
|
||||
static size_t h1_nego_ff(struct stconn *sc, struct buffer *input, size_t count, unsigned int flags)
|
||||
|
12
src/mux_pt.c
12
src/mux_pt.c
@ -19,7 +19,6 @@
|
||||
#include <haproxy/stream.h>
|
||||
#include <haproxy/task.h>
|
||||
#include <haproxy/trace.h>
|
||||
#include <haproxy/xref.h>
|
||||
|
||||
struct mux_pt_ctx {
|
||||
struct sedesc *sd;
|
||||
@ -561,16 +560,7 @@ static size_t mux_pt_snd_buf(struct stconn *sc, struct buffer *buf, size_t count
|
||||
|
||||
static inline struct sedesc *mux_pt_opposite_sd(struct mux_pt_ctx *ctx)
|
||||
{
|
||||
struct xref *peer;
|
||||
struct sedesc *sdo;
|
||||
|
||||
peer = xref_get_peer_and_lock(&ctx->sd->xref);
|
||||
if (!peer)
|
||||
return NULL;
|
||||
|
||||
sdo = container_of(peer, struct sedesc, xref);
|
||||
xref_unlock(&ctx->sd->xref, peer);
|
||||
return sdo;
|
||||
return se_opposite(ctx->sd);
|
||||
}
|
||||
|
||||
static size_t mux_pt_nego_ff(struct stconn *sc, struct buffer *input, size_t count, unsigned int flags)
|
||||
|
24
src/stconn.c
24
src/stconn.c
@ -141,6 +141,8 @@ void sedesc_free(struct sedesc *sedesc)
|
||||
*/
|
||||
void se_shutdown(struct sedesc *sedesc, enum se_shut_mode mode)
|
||||
{
|
||||
struct sedesc *sdo;
|
||||
struct se_abort_info *reason = NULL;
|
||||
unsigned int flags = 0;
|
||||
|
||||
if ((mode & (SE_SHW_SILENT|SE_SHW_NORMAL)) && !se_fl_test(sedesc, SE_FL_SHW))
|
||||
@ -153,16 +155,9 @@ void se_shutdown(struct sedesc *sedesc, enum se_shut_mode mode)
|
||||
|
||||
if (flags) {
|
||||
if (mux && mux->shut) {
|
||||
struct se_abort_info *reason = NULL;
|
||||
struct xref *peer = xref_get_peer_and_lock(&sedesc->xref);
|
||||
|
||||
if (peer) {
|
||||
struct sedesc *sdo = container_of(peer, struct sedesc, xref);
|
||||
|
||||
sdo = se_opposite(sedesc);
|
||||
if (sdo)
|
||||
reason = &sdo->abort_info;
|
||||
xref_unlock(&sedesc->xref, peer);
|
||||
}
|
||||
|
||||
mux->shut(sedesc->sc, mode, reason);
|
||||
}
|
||||
se_fl_set(sedesc, flags);
|
||||
@ -173,16 +168,9 @@ void se_shutdown(struct sedesc *sedesc, enum se_shut_mode mode)
|
||||
|
||||
if (flags) {
|
||||
if (appctx->applet->shut) {
|
||||
struct se_abort_info *reason = NULL;
|
||||
struct xref *peer = xref_get_peer_and_lock(&sedesc->xref);
|
||||
|
||||
if (peer) {
|
||||
struct sedesc *sdo = container_of(peer, struct sedesc, xref);
|
||||
|
||||
sdo = se_opposite(sedesc);
|
||||
if (sdo)
|
||||
reason = &sdo->abort_info;
|
||||
xref_unlock(&sedesc->xref, peer);
|
||||
}
|
||||
|
||||
appctx->applet->shut(appctx, mode, reason);
|
||||
}
|
||||
se_fl_set(sedesc, flags);
|
||||
|
Loading…
Reference in New Issue
Block a user