void
ngx_tcp_session_internal_server_error(ngx_tcp_session_t *s)
{
    ngx_tcp_core_srv_conf_t  *cscf;

    cscf = ngx_tcp_get_module_srv_conf(s, ngx_tcp_core_module);

    s->out = cscf->protocol->internal_server_error;
    s->quit = 1;

    ngx_tcp_send(s->connection->write);
}
Exemplo n.º 2
0
long 
ngx_tcp_send_data(ngx_tcp_ctx_t *ctx, const u_char *data, int len)
{
    ngx_chain_t                *out_chain;
    size_t                      data_copyed;
    ngx_chain_t                *cl;
    ngx_tcp_session_t          *s;
    ngx_connection_t           *c;

    s = ctx->ngx_tcp_session;
    c = s->connection;
    out_chain = ngx_tcp_chain_get_free_buf(s->output_ctx, len);
    if (NULL == out_chain) {
        ngx_log_error(NGX_LOG_ERR, c->log, 0, 
            "ngx_tcp_send_data|client=%V|out_chain==NULL\n", &c->addr_text);
        return -1;
    }

    data_copyed = 0;
    for (cl = out_chain; cl; cl = cl->next) {
        size_t to_copy = cl->buf->end - cl->buf->start;
        to_copy = ngx_min((len - data_copyed), to_copy);
        ngx_memcpy(cl->buf->pos, data + data_copyed, to_copy);
        data_copyed += to_copy;
        cl->buf->last += to_copy;
    }
    if (s->output_buffer_chain == NULL) {
        s->output_buffer_chain = out_chain;
    } else {
        cl = s->output_buffer_chain;
        while (cl->next != NULL) {
            cl = cl->next;
        }
        cl->next = out_chain;
    }

    ctx->pkg_send_count++;
    ngx_tcp_send(c->write);

    return 0;
}
void
ngx_tcp_session_internal_server_error(ngx_tcp_session_t *s)
{
    ngx_tcp_send(s->connection->write);
}