mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-10 03:02:28 +00:00
MEDIUM: connection: inform si_alloc_conn() whether existing conn is OK or not
When allocating a new connection, only the caller knows whether it's acceptable to reuse the previous one or not. Let's pass this information to si_alloc_conn() which will do the cleanup if the connection is not acceptable.
This commit is contained in:
parent
16bfb021c8
commit
9471b8ced9
@ -126,7 +126,8 @@ static inline void conn_full_close(struct connection *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Force to close the connection whatever the tracking state. This is mainly
|
/* Force to close the connection whatever the tracking state. This is mainly
|
||||||
* used on the error path where the tracking does not make sense.
|
* used on the error path where the tracking does not make sense, or to kill
|
||||||
|
* an idle connection we want to abort immediately.
|
||||||
*/
|
*/
|
||||||
static inline void conn_force_close(struct connection *conn)
|
static inline void conn_force_close(struct connection *conn)
|
||||||
{
|
{
|
||||||
|
@ -212,11 +212,15 @@ static inline void si_applet_release(struct stream_interface *si)
|
|||||||
applet->release(si);
|
applet->release(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Try to allocate a new connection and assign it to the interface. If
|
||||||
|
* a connection was previously allocated and the <reuse> flag is set,
|
||||||
|
* it is returned unmodified. Otherwise it is reset.
|
||||||
|
*/
|
||||||
/* Returns the stream interface's existing connection if one such already
|
/* Returns the stream interface's existing connection if one such already
|
||||||
* exists, or tries to allocate and initialize a new one which is then
|
* exists, or tries to allocate and initialize a new one which is then
|
||||||
* assigned to the stream interface.
|
* assigned to the stream interface.
|
||||||
*/
|
*/
|
||||||
static inline struct connection *si_alloc_conn(struct stream_interface *si)
|
static inline struct connection *si_alloc_conn(struct stream_interface *si, int reuse)
|
||||||
{
|
{
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
|
|
||||||
@ -225,8 +229,13 @@ static inline struct connection *si_alloc_conn(struct stream_interface *si)
|
|||||||
*/
|
*/
|
||||||
if (si->end) {
|
if (si->end) {
|
||||||
conn = objt_conn(si->end);
|
conn = objt_conn(si->end);
|
||||||
if (conn)
|
if (conn) {
|
||||||
|
if (!reuse) {
|
||||||
|
conn_force_close(conn);
|
||||||
|
conn_init(conn);
|
||||||
|
}
|
||||||
return conn;
|
return conn;
|
||||||
|
}
|
||||||
/* it was an applet then */
|
/* it was an applet then */
|
||||||
si_release_endpoint(si);
|
si_release_endpoint(si);
|
||||||
}
|
}
|
||||||
|
@ -982,7 +982,7 @@ static void assign_tproxy_address(struct session *s)
|
|||||||
int connect_server(struct session *s)
|
int connect_server(struct session *s)
|
||||||
{
|
{
|
||||||
struct connection *cli_conn;
|
struct connection *cli_conn;
|
||||||
struct connection *srv_conn = si_alloc_conn(s->req->cons);
|
struct connection *srv_conn = si_alloc_conn(s->req->cons, 0);
|
||||||
struct server *srv;
|
struct server *srv;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -3742,7 +3742,8 @@ int http_process_request(struct session *s, struct channel *req, int an_bit)
|
|||||||
if ((s->be->options & PR_O_HTTP_PROXY) && !(s->flags & SN_ADDR_SET)) {
|
if ((s->be->options & PR_O_HTTP_PROXY) && !(s->flags & SN_ADDR_SET)) {
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
|
|
||||||
if (unlikely((conn = si_alloc_conn(req->cons)) == NULL)) {
|
/* Note that for now we don't reuse existing proxy connections */
|
||||||
|
if (unlikely((conn = si_alloc_conn(req->cons, 0)) == NULL)) {
|
||||||
txn->req.msg_state = HTTP_MSG_ERROR;
|
txn->req.msg_state = HTTP_MSG_ERROR;
|
||||||
txn->status = 500;
|
txn->status = 500;
|
||||||
req->analysers = 0;
|
req->analysers = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user