REORG: move applet.h to haproxy/applet{,-t}.h
The type file was slightly tidied. The cli-specific APPCTX_CLI_ST1_* flag
definitions were moved to cli.h. The type file was adjusted to include
buf-t.h and not the huge buf.h. A few call places were fixed because they
did not need this include.
diff --git a/include/proto/applet.h b/include/proto/applet.h
deleted file mode 100644
index 48437f5..0000000
--- a/include/proto/applet.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * include/proto/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 _PROTO_APPLET_H
-#define _PROTO_APPLET_H
-
-#include <stdlib.h>
-
-#include <haproxy/api.h>
-#include <haproxy/pool.h>
-#include <haproxy/list.h>
-#include <types/applet.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 short state);
-
-int appctx_buf_available(void *arg);
-
-
-/* Initializes all required fields for a new appctx. Note that it does the
- * minimum acceptable initialization for an appctx. This means only the
- * 3 integer states st0, st1, st2 and the chunk used to gather unfinished
- * commands are zeroed
- */
-static inline void appctx_init(struct appctx *appctx, unsigned long thread_mask)
-{
- appctx->st0 = appctx->st1 = appctx->st2 = 0;
- appctx->chunk = NULL;
- appctx->io_release = NULL;
- appctx->thread_mask = thread_mask;
- appctx->call_rate.curr_sec = 0;
- appctx->call_rate.curr_ctr = 0;
- appctx->call_rate.prev_ctr = 0;
- appctx->state = 0;
- LIST_INIT(&appctx->wait_entry);
-}
-
-/* Tries to allocate a new appctx and initialize its main fields. The appctx
- * is returned on success, NULL on failure. The appctx must be released using
- * appctx_free(). <applet> is assigned as the applet, but it can be NULL.
- */
-static inline struct appctx *appctx_new(struct applet *applet, unsigned long thread_mask)
-{
- struct appctx *appctx;
-
- appctx = pool_alloc(pool_head_appctx);
- if (likely(appctx != NULL)) {
- appctx->obj_type = OBJ_TYPE_APPCTX;
- appctx->applet = applet;
- appctx_init(appctx, thread_mask);
- appctx->t = task_new(thread_mask);
- if (unlikely(appctx->t == NULL)) {
- pool_free(pool_head_appctx, appctx);
- return NULL;
- }
- appctx->t->process = task_run_applet;
- appctx->t->context = appctx;
- MT_LIST_INIT(&appctx->buffer_wait.list);
- appctx->buffer_wait.target = appctx;
- appctx->buffer_wait.wakeup_cb = appctx_buf_available;
- _HA_ATOMIC_ADD(&nb_applets, 1);
- }
- return appctx;
-}
-
-/* Releases an appctx previously allocated by appctx_new(). */
-static inline void __appctx_free(struct appctx *appctx)
-{
- task_destroy(appctx->t);
- if (MT_LIST_ADDED(&appctx->buffer_wait.list))
- MT_LIST_DEL(&appctx->buffer_wait.list);
-
- pool_free(pool_head_appctx, appctx);
- _HA_ATOMIC_SUB(&nb_applets, 1);
-}
-
-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 /* _PROTO_APPLET_H */
-
-/*
- * Local variables:
- * c-indent-level: 8
- * c-basic-offset: 8
- * End:
- */
diff --git a/include/proto/cli.h b/include/proto/cli.h
index 13490af..cbd3cd9 100644
--- a/include/proto/cli.h
+++ b/include/proto/cli.h
@@ -23,8 +23,8 @@
#ifndef _PROTO_CLI_H
#define _PROTO_CLI_H
+#include <haproxy/applet-t.h>
#include <haproxy/global.h>
-#include <types/applet.h>
#include <types/channel.h>
#include <types/cli.h>
#include <types/stream.h>
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 6a9aa55..f5f0bf3 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -22,11 +22,11 @@
#ifndef _PROTO_PROXY_H
#define _PROTO_PROXY_H
+#include <haproxy/applet-t.h>
#include <haproxy/api.h>
#include <haproxy/listener-t.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>
-#include <types/applet.h>
#include <haproxy/global-t.h>
#include <types/proxy.h>
#include <haproxy/freq_ctr.h>
diff --git a/include/proto/server.h b/include/proto/server.h
index b84be43..4d78c1d 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -24,10 +24,10 @@
#include <unistd.h>
+#include <haproxy/applet-t.h>
#include <haproxy/api.h>
#include <haproxy/dns-t.h>
#include <haproxy/time.h>
-#include <types/applet.h>
#include <types/proxy.h>
#include <types/queue.h>
#include <types/server.h>
diff --git a/include/proto/stats.h b/include/proto/stats.h
index f98a5ec..84c64d0 100644
--- a/include/proto/stats.h
+++ b/include/proto/stats.h
@@ -23,9 +23,9 @@
#ifndef _PROTO_STATS_H
#define _PROTO_STATS_H
+#include <haproxy/applet-t.h>
#include <haproxy/tools.h>
#include <haproxy/api.h>
-#include <types/applet.h>
#include <types/stream_interface.h>
#include <types/stats.h>
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index e381d84..f17e6ae 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -24,11 +24,11 @@
#include <stdlib.h>
+#include <haproxy/applet.h>
#include <haproxy/api.h>
#include <haproxy/connection.h>
#include <types/stream.h>
#include <types/stream_interface.h>
-#include <proto/applet.h>
#include <proto/channel.h>