#include <haproxy/htx-t.h>
#include <haproxy/obj_type.h>
#include <haproxy/stconn-t.h>
+#include <haproxy/xref.h>
struct buffer;
struct session;
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)
{
#include <haproxy/task.h>
#include <haproxy/trace.h>
#include <haproxy/vecpair.h>
-#include <haproxy/xref.h>
unsigned int nb_applets = 0;
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;
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;
#include <haproxy/stconn.h>
#include <haproxy/stream.h>
#include <haproxy/trace.h>
-#include <haproxy/xref.h>
/* H1 connection descriptor */
struct h1c {
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)
#include <haproxy/stream.h>
#include <haproxy/task.h>
#include <haproxy/trace.h>
-#include <haproxy/xref.h>
struct mux_pt_ctx {
struct sedesc *sd;
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)
*/
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))
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);
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);