Esempio n. 1
0
void
req_server_enqueue_imsgq(struct context *ctx, struct conn *conn, struct msg *msg)
{
    ASSERT(msg->request);
    ASSERT((!conn->client && !conn->proxy) || (!conn->dnode_client && !conn->dnode_server));

    /*
     * timeout clock starts ticking the instant the message is enqueued into
     * the server in_q; the clock continues to tick until it either expires
     * or the message is dequeued from the server out_q
     *
     * noreply request are free from timeouts because client is not interested
     * in the reponse anyway!
     */
    if (!msg->noreply) {
        msg_tmo_insert(msg, conn);
    }

    TAILQ_INSERT_TAIL(&conn->imsg_q, msg, s_tqe);

    if (!conn->dyn_mode) {
       stats_server_incr(ctx, conn->owner, in_queue);
       stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen);
    } else {
       struct server_pool *pool = (struct server_pool *) array_get(&ctx->pool, 0);
       stats_pool_incr(ctx, pool, peer_in_queue);
       stats_pool_incr_by(ctx, pool, peer_in_queue_bytes, msg->mlen);
    }
}
Esempio n. 2
0
void
req_server_enqueue_imsgq_head(struct context *ctx, struct conn *conn, struct msg *msg)
{
    ASSERT(msg->request);
    ASSERT(!conn->client && !conn->proxy);

    /*
     * timeout clock starts ticking the instant the message is enqueued into
     * the server in_q; the clock continues to tick until it either expires
     * or the message is dequeued from the server out_q
     *
     * noreply request are free from timeouts because client is not intrested
     * in the reponse anyway!
     */
    if (!msg->noreply) {
        msg_tmo_insert(msg, conn);
    }

    TAILQ_INSERT_HEAD(&conn->imsg_q, msg, s_tqe);

    stats_server_incr(ctx, conn->owner, in_queue);
    stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen);
}
Esempio n. 3
0
//接收的客户端msg信息通过req_server_enqueue_imsgq添加到该队列 在req_send_next中发往后端真实服务器
//msg数据添加到conn->imsg_q队列入队,在req_send_next中发往后端真实服务器
void   //req_server_enqueue_imsgq添加到队列尾部,req_server_enqueue_imsgq_head添加到队列头部
req_server_enqueue_imsgq(struct context *ctx, struct conn *conn, struct msg *msg)
{//req_forward中执行  req_forward->req_server_enqueue_imsgq
    ASSERT(msg->request);
    ASSERT(!conn->client && !conn->proxy);

    /*
     * timeout clock starts ticking the instant the message is enqueued into
     * the server in_q; the clock continues to tick until it either expires
     * or the message is dequeued from the server out_q
     *
     * noreply request are free from timeouts because client is not intrested
     * in the response anyway!
     */
    if (!msg->noreply) { //该msg需要得到应答,添加到红黑树超时定时器
        //该定时器在core_timeout中删除
        msg_tmo_insert(msg, conn); //添加到tmo_rbt   该msg需要发往后端真实服务器,并且需要等待对方应答
    }

    TAILQ_INSERT_TAIL(&conn->imsg_q, msg, s_tqe);//在core_core中的写事件把imsg_q中的msg发送出去

    stats_server_incr(ctx, conn->owner, in_queue); 
    stats_server_incr_by(ctx, conn->owner, in_queue_bytes, msg->mlen);
}