static void hlua_socket_handler(struct appctx *appctx)
{
struct hlua_csk_ctx *ctx = appctx->svcctx;
- struct stconn *cs = appctx_cs(appctx);
+ struct stconn *sc = appctx_cs(appctx);
if (ctx->die) {
- sc_shutw(cs);
- sc_shutr(cs);
- sc_ic(cs)->flags |= CF_READ_NULL;
+ sc_shutw(sc);
+ sc_shutr(sc);
+ sc_ic(sc)->flags |= CF_READ_NULL;
notification_wake(&ctx->wake_on_read);
notification_wake(&ctx->wake_on_write);
- stream_shutdown(__sc_strm(cs), SF_ERR_KILLED);
+ stream_shutdown(__sc_strm(sc), SF_ERR_KILLED);
}
/* If we can't write, wakeup the pending write signals. */
- if (channel_output_closed(sc_ic(cs)))
+ if (channel_output_closed(sc_ic(sc)))
notification_wake(&ctx->wake_on_write);
/* If we can't read, wakeup the pending read signals. */
- if (channel_input_closed(sc_oc(cs)))
+ if (channel_input_closed(sc_oc(sc)))
notification_wake(&ctx->wake_on_read);
/* if the connection is not established, inform the stream that we want
* to be notified whenever the connection completes.
*/
- if (sc_opposite(cs)->state < SC_ST_EST) {
+ if (sc_opposite(sc)->state < SC_ST_EST) {
applet_need_more_data(appctx);
se_need_remote_conn(appctx->sedesc);
applet_have_more_data(appctx);
ctx->connected = 1;
/* Wake the tasks which wants to write if the buffer have available space. */
- if (channel_may_recv(sc_ic(cs)))
+ if (channel_may_recv(sc_ic(sc)))
notification_wake(&ctx->wake_on_write);
/* Wake the tasks which wants to read if the buffer contains data. */
- if (!channel_is_empty(sc_oc(cs)))
+ if (!channel_is_empty(sc_oc(sc)))
notification_wake(&ctx->wake_on_read);
/* Some data were injected in the buffer, notify the stream
* interface.
*/
- if (!channel_is_empty(sc_ic(cs)))
- sc_update(cs);
+ if (!channel_is_empty(sc_ic(sc)))
+ sc_update(sc);
/* If write notifications are registered, we considers we want
* to write, so we clear the blocking flag.
int sent;
struct xref *peer;
struct stream *s;
- struct stconn *cs;
+ struct stconn *sc;
/* Get hlua struct, or NULL if we execute from main lua state */
hlua = hlua_gethlua(L);
csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
appctx = csk_ctx->appctx;
- cs = appctx_cs(appctx);
- s = __sc_strm(cs);
+ sc = appctx_cs(appctx);
+ s = __sc_strm(sc);
/* Check for connection close. */
if (channel_output_closed(&s->req)) {
* the request buffer if its not required.
*/
if (s->req.buf.size == 0) {
- if (!sc_alloc_ibuf(cs, &appctx->buffer_wait))
+ if (!sc_alloc_ibuf(sc, &appctx->buffer_wait))
goto hlua_socket_write_yield_return;
}
struct hlua_socket *socket;
struct xref *peer;
struct appctx *appctx;
- struct stconn *cs;
+ struct stconn *sc;
const struct sockaddr_storage *dst;
int ret;
}
appctx = container_of(peer, struct hlua_csk_ctx, xref)->appctx;
- cs = appctx_cs(appctx);
- dst = sc_dst(sc_opposite(cs));
+ sc = appctx_cs(appctx);
+ dst = sc_dst(sc_opposite(sc));
if (!dst) {
xref_unlock(&socket->xref, peer);
lua_pushnil(L);
int low, high;
struct sockaddr_storage *addr;
struct xref *peer;
- struct stconn *cs;
+ struct stconn *sc;
struct stream *s;
if (lua_gettop(L) < 2)
csk_ctx = container_of(peer, struct hlua_csk_ctx, xref);
appctx = csk_ctx->appctx;
- cs = appctx_cs(appctx);
- s = __sc_strm(cs);
+ sc = appctx_cs(appctx);
+ s = __sc_strm(sc);
- if (!sockaddr_alloc(&sc_opposite(cs)->dst, addr, sizeof(*addr))) {
+ if (!sockaddr_alloc(&sc_opposite(sc)->dst, addr, sizeof(*addr))) {
xref_unlock(&socket->xref, peer);
WILL_LJMP(luaL_error(L, "connect: internal error"));
}
__LJMP static int hlua_applet_tcp_getline_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
+ struct stconn *sc = appctx_cs(luactx->appctx);
int ret;
const char *blk1;
size_t len1;
size_t len2;
/* Read the maximum amount of data available. */
- ret = co_getline_nc(sc_oc(cs), &blk1, &len1, &blk2, &len2);
+ ret = co_getline_nc(sc_oc(sc), &blk1, &len1, &blk2, &len2);
/* Data not yet available. return yield. */
if (ret == 0) {
luaL_addlstring(&luactx->b, blk2, len2);
/* Consume input channel output buffer data. */
- co_skip(sc_oc(cs), len1 + len2);
+ co_skip(sc_oc(sc), len1 + len2);
luaL_pushresult(&luactx->b);
return 1;
}
__LJMP static int hlua_applet_tcp_recv_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
+ struct stconn *sc = appctx_cs(luactx->appctx);
size_t len = MAY_LJMP(luaL_checkinteger(L, 2));
int ret;
const char *blk1;
size_t len2;
/* Read the maximum amount of data available. */
- ret = co_getblk_nc(sc_oc(cs), &blk1, &len1, &blk2, &len2);
+ ret = co_getblk_nc(sc_oc(sc), &blk1, &len1, &blk2, &len2);
/* Data not yet available. return yield. */
if (ret == 0) {
*/
luaL_addlstring(&luactx->b, blk1, len1);
luaL_addlstring(&luactx->b, blk2, len2);
- co_skip(sc_oc(cs), len1 + len2);
+ co_skip(sc_oc(sc), len1 + len2);
applet_need_more_data(luactx->appctx);
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_recv_yield, TICK_ETERNITY, 0));
len -= len2;
/* Consume input channel output buffer data. */
- co_skip(sc_oc(cs), len1 + len2);
+ co_skip(sc_oc(sc), len1 + len2);
/* If there is no other data available, yield waiting for new data. */
if (len > 0) {
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_tcp(L, 1));
const char *str = MAY_LJMP(luaL_checklstring(L, 2, &len));
int l = MAY_LJMP(luaL_checkinteger(L, 3));
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *chn = sc_ic(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *chn = sc_ic(sc);
int max;
/* Get the max amount of data which can write as input in the channel. */
* applet, and returns a yield.
*/
if (l < len) {
- sc_need_room(cs);
+ sc_need_room(sc);
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_tcp_send_yield, TICK_ETERNITY, 0));
}
__LJMP static int hlua_applet_http_getline_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *req = sc_oc(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *req = sc_oc(sc);
struct htx *htx;
struct htx_blk *blk;
size_t count;
__LJMP static int hlua_applet_http_recv_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *req = sc_oc(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *req = sc_oc(sc);
struct htx *htx;
struct htx_blk *blk;
size_t count;
__LJMP static int hlua_applet_http_send_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *res = sc_ic(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *res = sc_ic(sc);
struct htx *htx = htx_from_buf(&res->buf);
const char *data;
size_t len;
if (l < len) {
snd_yield:
htx_to_buf(htx, &res->buf);
- sc_need_room(cs);
+ sc_need_room(sc);
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_send_yield, TICK_ETERNITY, 0));
}
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
struct hlua_http_ctx *http_ctx = luactx->appctx->svcctx;
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *res = sc_ic(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *res = sc_ic(sc);
struct htx *htx;
struct htx_sl *sl;
struct h1m h1m;
__LJMP static int hlua_applet_http_start_response_yield(lua_State *L, int status, lua_KContext ctx)
{
struct hlua_appctx *luactx = MAY_LJMP(hlua_checkapplet_http(L, 1));
- struct stconn *cs = appctx_cs(luactx->appctx);
- struct channel *res = sc_ic(cs);
+ struct stconn *sc = appctx_cs(luactx->appctx);
+ struct channel *res = sc_ic(sc);
if (co_data(res)) {
- sc_need_room(cs);
+ sc_need_room(sc);
MAY_LJMP(hlua_yieldk(L, 0, 0, hlua_applet_http_start_response_yield, TICK_ETERNITY, 0));
}
return MAY_LJMP(hlua_applet_http_send_response(L));
static int hlua_applet_tcp_init(struct appctx *ctx)
{
struct hlua_tcp_ctx *tcp_ctx = applet_reserve_svcctx(ctx, sizeof(*tcp_ctx));
- struct stconn *cs = appctx_cs(ctx);
- struct stream *strm = __sc_strm(cs);
+ struct stconn *sc = appctx_cs(ctx);
+ struct stream *strm = __sc_strm(sc);
struct hlua *hlua;
struct task *task;
char **arg;
void hlua_applet_tcp_fct(struct appctx *ctx)
{
struct hlua_tcp_ctx *tcp_ctx = ctx->svcctx;
- struct stconn *cs = appctx_cs(ctx);
- struct stream *strm = __sc_strm(cs);
- struct channel *res = sc_ic(cs);
+ struct stconn *sc = appctx_cs(ctx);
+ struct stream *strm = __sc_strm(sc);
+ struct channel *res = sc_ic(sc);
struct act_rule *rule = ctx->rule;
struct proxy *px = strm->be;
struct hlua *hlua = tcp_ctx->hlua;
/* The applet execution is already done. */
if (tcp_ctx->flags & APPLET_DONE) {
/* eat the whole request */
- co_skip(sc_oc(cs), co_data(sc_oc(cs)));
+ co_skip(sc_oc(sc), co_data(sc_oc(sc)));
return;
}
/* If the stream is disconnect or closed, ldo nothing. */
- if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO))
+ if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
return;
/* Execute the function. */
tcp_ctx->flags |= APPLET_DONE;
/* eat the whole request */
- co_skip(sc_oc(cs), co_data(sc_oc(cs)));
+ co_skip(sc_oc(sc), co_data(sc_oc(sc)));
res->flags |= CF_READ_NULL;
- sc_shutr(cs);
+ sc_shutr(sc);
return;
/* yield. */
error:
/* For all other cases, just close the stream. */
- sc_shutw(cs);
- sc_shutr(cs);
+ sc_shutw(sc);
+ sc_shutr(sc);
tcp_ctx->flags |= APPLET_DONE;
}
static int hlua_applet_http_init(struct appctx *ctx)
{
struct hlua_http_ctx *http_ctx = applet_reserve_svcctx(ctx, sizeof(*http_ctx));
- struct stconn *cs = appctx_cs(ctx);
- struct stream *strm = __sc_strm(cs);
+ struct stconn *sc = appctx_cs(ctx);
+ struct stream *strm = __sc_strm(sc);
struct http_txn *txn;
struct hlua *hlua;
char **arg;
void hlua_applet_http_fct(struct appctx *ctx)
{
struct hlua_http_ctx *http_ctx = ctx->svcctx;
- struct stconn *cs = appctx_cs(ctx);
- struct stream *strm = __sc_strm(cs);
- struct channel *req = sc_oc(cs);
- struct channel *res = sc_ic(cs);
+ struct stconn *sc = appctx_cs(ctx);
+ struct stream *strm = __sc_strm(sc);
+ struct channel *req = sc_oc(sc);
+ struct channel *res = sc_ic(sc);
struct act_rule *rule = ctx->rule;
struct proxy *px = strm->be;
struct hlua *hlua = http_ctx->hlua;
res_htx = htx_from_buf(&res->buf);
/* If the stream is disconnect or closed, ldo nothing. */
- if (unlikely(cs->state == SC_ST_DIS || cs->state == SC_ST_CLO))
+ if (unlikely(sc->state == SC_ST_DIS || sc->state == SC_ST_CLO))
goto out;
/* Check if the input buffer is available. */
if (!b_size(&res->buf)) {
- sc_need_room(cs);
+ sc_need_room(sc);
goto out;
}
/* check that the output is not closed */
*/
if (htx_is_empty(res_htx) && (strm->txn->rsp.flags & (HTTP_MSGF_XFER_LEN|HTTP_MSGF_CNT_LEN)) == HTTP_MSGF_XFER_LEN) {
if (!htx_add_endof(res_htx, HTX_BLK_EOT)) {
- sc_need_room(cs);
+ sc_need_room(sc);
goto out;
}
channel_add_input(res, 1);
if (http_ctx->flags & APPLET_DONE) {
if (!(res->flags & CF_SHUTR)) {
res->flags |= CF_READ_NULL;
- sc_shutr(cs);
+ sc_shutr(sc);
}
/* eat the whole request */