mirror of
http://git.haproxy.org/git/haproxy.git
synced 2026-02-18 13:36:41 +02:00
The conn-stream endpoint is now shared between the conn-stream and the applet or the multiplexer. If the mux or the applet is created first, it is responsible to also create the endpoint and share it with the conn-stream. If the conn-stream is created first, it is the opposite. When the endpoint is only owned by an applet or a mux, it is called an orphan endpoint (there is no conn-stream). When it is only owned by a conn-stream, it is called a detached endpoint (there is no mux/applet). The last entity that owns an endpoint is responsible to release it. When a mux or an applet is detached from a conn-stream, the conn-stream relinquishes the endpoint to recreate a new one. This way, the endpoint state is never lost for the mux or the applet.
85 lines
2.4 KiB
C
85 lines
2.4 KiB
C
/*
|
|
* include/haproxy/applet.h
|
|
* This file contains applet function prototypes
|
|
*
|
|
* Copyright (C) 2000-2015 Willy Tarreau - w@1wt.eu
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation, version 2.1
|
|
* exclusively.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
|
|
#ifndef _HAPROXY_APPLET_H
|
|
#define _HAPROXY_APPLET_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <haproxy/api.h>
|
|
#include <haproxy/applet-t.h>
|
|
#include <haproxy/conn_stream.h>
|
|
#include <haproxy/list.h>
|
|
#include <haproxy/pool.h>
|
|
#include <haproxy/task.h>
|
|
|
|
extern unsigned int nb_applets;
|
|
extern struct pool_head *pool_head_appctx;
|
|
|
|
struct task *task_run_applet(struct task *t, void *context, unsigned int state);
|
|
int appctx_buf_available(void *arg);
|
|
|
|
struct appctx *appctx_new(struct applet *applet, struct cs_endpoint *endp);
|
|
|
|
/* Releases an appctx previously allocated by appctx_new(). */
|
|
static inline void __appctx_free(struct appctx *appctx)
|
|
{
|
|
task_destroy(appctx->t);
|
|
if (LIST_INLIST(&appctx->buffer_wait.list))
|
|
LIST_DEL_INIT(&appctx->buffer_wait.list);
|
|
|
|
BUG_ON(appctx->endp && !(appctx->endp->flags & CS_EP_ORPHAN));
|
|
cs_endpoint_free(appctx->endp);
|
|
pool_free(pool_head_appctx, appctx);
|
|
_HA_ATOMIC_DEC(&nb_applets);
|
|
}
|
|
|
|
static inline void appctx_free(struct appctx *appctx)
|
|
{
|
|
/* The task is supposed to be run on this thread, so we can just
|
|
* check if it's running already (or about to run) or not
|
|
*/
|
|
if (!(appctx->t->state & (TASK_QUEUED | TASK_RUNNING)))
|
|
__appctx_free(appctx);
|
|
else {
|
|
/* if it's running, or about to run, defer the freeing
|
|
* until the callback is called.
|
|
*/
|
|
appctx->state |= APPLET_WANT_DIE;
|
|
task_wakeup(appctx->t, TASK_WOKEN_OTHER);
|
|
}
|
|
}
|
|
|
|
/* wakes up an applet when conditions have changed */
|
|
static inline void appctx_wakeup(struct appctx *appctx)
|
|
{
|
|
task_wakeup(appctx->t, TASK_WOKEN_OTHER);
|
|
}
|
|
|
|
#endif /* _HAPROXY_APPLET_H */
|
|
|
|
/*
|
|
* Local variables:
|
|
* c-indent-level: 8
|
|
* c-basic-offset: 8
|
|
* End:
|
|
*/
|