}
else if ((appctx = objt_appctx(si->end))) {
if (appctx->applet->release)
- appctx->applet->release(si);
+ appctx->applet->release(appctx);
appctx_free(appctx); /* we share the connection pool */
}
si->end = NULL;
return objt_appctx(si->end);
}
-/* returns a pointer to the applet being run in the SI or NULL if none */
-static inline const struct si_applet *si_applet(struct stream_interface *si)
-{
- const struct appctx *appctx;
-
- appctx = si_appctx(si);
- if (appctx)
- return appctx->applet;
- return NULL;
-}
-
/* Call the applet's main function when an appctx is attached to the stream
* interface. Returns zero if no call was made, or non-zero if a call was made.
*/
static inline int si_applet_call(struct stream_interface *si)
{
- const struct si_applet *applet;
+ struct appctx *appctx;
- applet = si_applet(si);
- if (applet) {
- applet->fct(si);
+ appctx = si_appctx(si);
+ if (appctx) {
+ appctx->applet->fct(appctx);
return 1;
}
return 0;
/* call the applet's release function if any. Needs to be called upon close() */
static inline void si_applet_release(struct stream_interface *si)
{
- const struct si_applet *applet;
+ struct appctx *appctx;
- applet = si_applet(si);
- if (applet && applet->release)
- applet->release(si);
+ appctx = si_appctx(si);
+ if (appctx && appctx->applet->release)
+ appctx->applet->release(appctx);
}
/* Try to allocate a new connection and assign it to the interface. If
int conn_retries; /* number of connect retries left */
};
+struct appctx;
+
/* An applet designed to run in a stream interface */
struct si_applet {
enum obj_type obj_type; /* object type = OBJ_TYPE_APPLET */
/* 3 unused bytes here */
char *name; /* applet's name to report in logs */
- void (*fct)(struct stream_interface *); /* internal I/O handler, may never be NULL */
- void (*release)(struct stream_interface *); /* callback to release resources, may be NULL */
+ void (*fct)(struct appctx *); /* internal I/O handler, may never be NULL */
+ void (*release)(struct appctx *); /* callback to release resources, may be NULL */
};
/* operations available on a stream-interface */
static int stats_pats_list(struct stream_interface *si);
static int stats_pat_list(struct stream_interface *si);
static int stats_map_lookup(struct stream_interface *si);
-static void cli_release_handler(struct stream_interface *si);
+static void cli_release_handler(struct appctx *appctx);
/*
* cli_io_handler()
* STAT_CLI_* constants. appctx->st1 is used to indicate whether prompt is enabled
* or not.
*/
-static void cli_io_handler(struct stream_interface *si)
+static void cli_io_handler(struct appctx *appctx)
{
- struct appctx *appctx = __objt_appctx(si->end);
+ struct stream_interface *si = appctx->owner;
struct channel *req = si_oc(si);
struct channel *res = si_ic(si);
int reql;
}
else { /* output functions: first check if the output buffer is closed then abort */
if (res->flags & (CF_SHUTR_NOW|CF_SHUTR)) {
- cli_release_handler(si);
+ cli_release_handler(appctx);
appctx->st0 = STAT_CLI_END;
continue;
}
appctx->st0 = STAT_CLI_PROMPT;
break;
default: /* abnormal state */
- cli_release_handler(si);
+ cli_release_handler(appctx);
appctx->st0 = STAT_CLI_PROMPT;
break;
}
* appctx->st0 contains the operation in progress (dump, done). The handler
* automatically unregisters itself once transfer is complete.
*/
-static void http_stats_io_handler(struct stream_interface *si)
+static void http_stats_io_handler(struct appctx *appctx)
{
- struct appctx *appctx = __objt_appctx(si->end);
+ struct stream_interface *si = appctx->owner;
struct stream *s = si_strm(si);
struct channel *req = si_oc(si);
struct channel *res = si_ic(si);
* external abort, we won't call the i/o handler anymore so we may need to
* remove back references to the stream currently being dumped.
*/
-static void cli_release_handler(struct stream_interface *si)
+static void cli_release_handler(struct appctx *appctx)
{
- struct appctx *appctx = __objt_appctx(si->end);
-
if (appctx->st0 == STAT_CLI_O_SESS && appctx->st2 == STAT_ST_LIST) {
if (!LIST_ISEMPTY(&appctx->ctx.sess.bref.users))
LIST_DEL(&appctx->ctx.sess.bref.users);
* connection. It is used for notify space avalaible to send or data
* received.
*/
-static void hlua_socket_handler(struct stream_interface *si)
+static void hlua_socket_handler(struct appctx *appctx)
{
- struct appctx *appctx = objt_appctx(si->end);
+ struct stream_interface *si = appctx->owner;
struct connection *c = objt_conn(si_opposite(si)->end);
/* Wakeup the main stream if the client connection is closed. */
* Remove the link from the object to this stream.
* Wake all the pending signals.
*/
-static void hlua_socket_release(struct stream_interface *si)
+static void hlua_socket_release(struct appctx *appctx)
{
- struct appctx *appctx = objt_appctx(si->end);
-
/* Remove my link in the original object. */
if (appctx->ctx.hlua.socket)
appctx->ctx.hlua.socket->s = NULL;
/*
* Callback to release a session with a peer
*/
-static void peer_session_release(struct stream_interface *si)
+static void peer_session_release(struct appctx *appctx)
{
+ struct stream_interface *si = appctx->owner;
struct stream *s = si_strm(si);
- struct appctx *appctx = objt_appctx(si->end);
struct peer_session *ps = (struct peer_session *)appctx->ctx.peers.ptr;
/* appctx->ctx.peers.ptr is not a peer session */
/*
* IO Handler to handle message exchance with a peer
*/
-static void peer_io_handler(struct stream_interface *si)
+static void peer_io_handler(struct appctx *appctx)
{
+ struct stream_interface *si = appctx->owner;
struct stream *s = si_strm(si);
struct peers *curpeers = (struct peers *)strm_fe(s)->parent;
- struct appctx *appctx = objt_appctx(si->end);
int reql = 0;
int repl = 0;
*/
static void peer_session_forceshutdown(struct stream * stream)
{
- struct stream_interface *oldsi = NULL;
struct appctx *appctx = NULL;
int i;
continue;
if (appctx->applet != &peer_applet)
continue;
-
- oldsi = &stream->si[i];
break;
}
return;
/* call release to reinit resync states if needed */
- peer_session_release(oldsi);
+ peer_session_release(appctx);
appctx->st0 = PEER_SESS_ST_END;
appctx->ctx.peers.ptr = NULL;
task_wakeup(stream->task, TASK_WOKEN_MSG);