MINOR: Add release callback to si_applet

This commit is contained in:
Aman Gupta 2012-04-02 18:57:53 -07:00 committed by Willy Tarreau
parent 19979e176e
commit 9a13e84cc2
4 changed files with 5 additions and 3 deletions

View File

@ -189,6 +189,7 @@ struct stream_interface {
struct si_applet { struct si_applet {
char *name; /* applet's name to report in logs */ char *name; /* applet's name to report in logs */
void (*fct)(struct stream_interface *); /* internal I/O handler, may never be NULL */ 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 */
}; };
#endif /* _TYPES_STREAM_INTERFACE_H */ #endif /* _TYPES_STREAM_INTERFACE_H */

View File

@ -3961,11 +3961,13 @@ static int stats_dump_errors_to_buffer(struct stream_interface *si)
struct si_applet http_stats_applet = { struct si_applet http_stats_applet = {
.name = "<STATS>", /* used for logging */ .name = "<STATS>", /* used for logging */
.fct = http_stats_io_handler, .fct = http_stats_io_handler,
.release = NULL,
}; };
static struct si_applet cli_applet = { static struct si_applet cli_applet = {
.name = "<CLI>", /* used for logging */ .name = "<CLI>", /* used for logging */
.fct = cli_io_handler, .fct = cli_io_handler,
.release = NULL,
}; };
static struct cfg_kw_list cfg_kws = {{ },{ static struct cfg_kw_list cfg_kws = {{ },{

View File

@ -1044,6 +1044,7 @@ static void peer_io_handler(struct stream_interface *si)
static struct si_applet peer_applet = { static struct si_applet peer_applet = {
.name = "<PEER>", /* used for logging */ .name = "<PEER>", /* used for logging */
.fct = peer_io_handler, .fct = peer_io_handler,
.release = peer_session_release,
}; };
/* /*
@ -1079,7 +1080,6 @@ int peer_accept(struct session *s)
/* we have a dedicated I/O handler for the stats */ /* we have a dedicated I/O handler for the stats */
stream_int_register_handler(&s->si[1], &peer_applet); stream_int_register_handler(&s->si[1], &peer_applet);
copy_target(&s->target, &s->si[1].target); // for logging only copy_target(&s->target, &s->si[1].target); // for logging only
s->si[1].release = peer_session_release;
s->si[1].applet.private = s; s->si[1].applet.private = s;
s->si[1].applet.st0 = PEER_SESSION_ACCEPT; s->si[1].applet.st0 = PEER_SESSION_ACCEPT;
@ -1165,7 +1165,6 @@ static struct session *peer_session_create(struct peer *peer, struct peer_sessio
s->si[0].applet.st0 = PEER_SESSION_CONNECT; s->si[0].applet.st0 = PEER_SESSION_CONNECT;
stream_int_register_handler(&s->si[0], &peer_applet); stream_int_register_handler(&s->si[0], &peer_applet);
s->si[0].release = peer_session_release;
s->si[1].fd = -1; /* just to help with debugging */ s->si[1].fd = -1; /* just to help with debugging */
s->si[1].owner = t; s->si[1].owner = t;

View File

@ -316,7 +316,7 @@ struct task *stream_int_register_handler(struct stream_interface *si, struct si_
si->connect = NULL; si->connect = NULL;
set_target_applet(&si->target, app); set_target_applet(&si->target, app);
si->applet.state = 0; si->applet.state = 0;
si->release = NULL; si->release = app->release;
si->flags |= SI_FL_WAIT_DATA; si->flags |= SI_FL_WAIT_DATA;
return si->owner; return si->owner;
} }