mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
MINOR: stconn: report that a buffer allocation succeeded
We used to have two states for the channel's input buffer used by the SC, NEED_BUFF or not, flipped by sc_need_buff() and sc_have_buff(). We want to have a 3rd state, indicating that we've just got a desired buffer. Let's add an HAVE_BUFF flag that is set by sc_have_buff() and that is cleared by sc_used_buff(). This way by looking at HAVE_BUFF we know that we're coming back from the allocation callback and that the offered buffer has not yet been used.
This commit is contained in:
parent
d1eb48a12b
commit
7aff64518c
@ -155,8 +155,11 @@ static inline int sc_alloc_ibuf(struct stconn *sc, struct buffer_wait *wait)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = channel_alloc_buffer(sc_ic(sc), wait);
|
ret = channel_alloc_buffer(sc_ic(sc), wait);
|
||||||
if (!ret)
|
if (ret)
|
||||||
|
sc_used_buff(sc);
|
||||||
|
else
|
||||||
sc_need_buff(sc);
|
sc_need_buff(sc);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,7 @@ enum sc_flags {
|
|||||||
SC_FL_SHUT_DONE = 0x00020000, /* A shutdown was performed for the SC */
|
SC_FL_SHUT_DONE = 0x00020000, /* A shutdown was performed for the SC */
|
||||||
|
|
||||||
SC_FL_EOS = 0x00040000, /* End of stream was reached (from down side to up side) */
|
SC_FL_EOS = 0x00040000, /* End of stream was reached (from down side to up side) */
|
||||||
|
SC_FL_HAVE_BUFF = 0x00080000, /* A buffer is ready, flag will be cleared once allocated */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This function is used to report flags in debugging tools. Please reflect
|
/* This function is used to report flags in debugging tools. Please reflect
|
||||||
@ -221,7 +222,7 @@ static forceinline char *sc_show_flags(char *buf, size_t len, const char *delim,
|
|||||||
_(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM,
|
_(SC_FL_NEED_BUFF, _(SC_FL_NEED_ROOM,
|
||||||
_(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE,
|
_(SC_FL_RCV_ONCE, _(SC_FL_SND_ASAP, _(SC_FL_SND_NEVERWAIT, _(SC_FL_SND_EXP_MORE,
|
||||||
_(SC_FL_ABRT_WANTED, _(SC_FL_SHUT_WANTED, _(SC_FL_ABRT_DONE, _(SC_FL_SHUT_DONE,
|
_(SC_FL_ABRT_WANTED, _(SC_FL_SHUT_WANTED, _(SC_FL_ABRT_DONE, _(SC_FL_SHUT_DONE,
|
||||||
_(SC_FL_EOS)))))))))))))))))));
|
_(SC_FL_EOS, _(SC_FL_HAVE_BUFF))))))))))))))))))));
|
||||||
/* epilogue */
|
/* epilogue */
|
||||||
_(~0U);
|
_(~0U);
|
||||||
return buf;
|
return buf;
|
||||||
|
@ -377,12 +377,15 @@ static inline void se_need_remote_conn(struct sedesc *se)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The application layer tells the stream connector that it just got the input
|
/* The application layer tells the stream connector that it just got the input
|
||||||
* buffer it was waiting for. A read activity is reported.
|
* buffer it was waiting for. A read activity is reported. The SC_FL_HAVE_BUFF
|
||||||
|
* flag is set and held until sc_used_buff() is called to indicatee it was
|
||||||
|
* used.
|
||||||
*/
|
*/
|
||||||
static inline void sc_have_buff(struct stconn *sc)
|
static inline void sc_have_buff(struct stconn *sc)
|
||||||
{
|
{
|
||||||
if (sc->flags & SC_FL_NEED_BUFF) {
|
if (sc->flags & SC_FL_NEED_BUFF) {
|
||||||
sc->flags &= ~SC_FL_NEED_BUFF;
|
sc->flags &= ~SC_FL_NEED_BUFF;
|
||||||
|
sc->flags |= SC_FL_HAVE_BUFF;
|
||||||
sc_ep_report_read_activity(sc);
|
sc_ep_report_read_activity(sc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -397,6 +400,14 @@ static inline void sc_need_buff(struct stconn *sc)
|
|||||||
sc->flags |= SC_FL_NEED_BUFF;
|
sc->flags |= SC_FL_NEED_BUFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The stream connector indicates that it has successfully allocated the buffer
|
||||||
|
* it was previously waiting for so it drops the SC_FL_HAVE_BUFF bit.
|
||||||
|
*/
|
||||||
|
static inline void sc_used_buff(struct stconn *sc)
|
||||||
|
{
|
||||||
|
sc->flags &= ~SC_FL_HAVE_BUFF;
|
||||||
|
}
|
||||||
|
|
||||||
/* Tell a stream connector some room was made in the input buffer and any
|
/* Tell a stream connector some room was made in the input buffer and any
|
||||||
* failed attempt to inject data into it may be tried again. This is usually
|
* failed attempt to inject data into it may be tried again. This is usually
|
||||||
* called after a successful transfer of buffer contents to the other side.
|
* called after a successful transfer of buffer contents to the other side.
|
||||||
|
Loading…
Reference in New Issue
Block a user