Lines Matching refs:c

16 static void proxy_process_command(conn *c, char *command, size_t cmdlen, bool multiget);
153 void proxy_stats(void *arg, ADD_STAT add_stats, void *c) { in proxy_stats() argument
171 void process_proxy_stats(void *arg, ADD_STAT add_stats, void *c) { in process_proxy_stats() argument
239 add_stats(key_str, pfxlen+nlen, vbuf, e-vbuf, c); in process_proxy_stats()
285 void process_proxy_funcstats(void *arg, ADD_STAT add_stats, void *c) { in process_proxy_funcstats() argument
321 void process_proxy_bestats(void *arg, ADD_STAT add_stats, void *c) { in process_proxy_bestats() argument
600 io_queue_t *q = conn_io_queue_get(p->c, p->io_queue_type); in proxy_return_rctx_cb()
602 conn *c = p->c; in proxy_return_rctx_cb() local
613 conn_worker_readd(c); in proxy_return_rctx_cb()
636 int try_read_command_proxy(conn *c) { in try_read_command_proxy() argument
639 if (c->rbytes == 0) in try_read_command_proxy()
642 el = memchr(c->rcurr, '\n', c->rbytes); in try_read_command_proxy()
644 if (c->rbytes > 1024) { in try_read_command_proxy()
649 char *ptr = c->rcurr; in try_read_command_proxy()
654 if (ptr - c->rcurr > 100 || in try_read_command_proxy()
657 conn_set_state(c, conn_closing); in try_read_command_proxy()
664 if (!c->rbuf_malloced) { in try_read_command_proxy()
665 if (!rbuf_switch_to_malloc(c)) { in try_read_command_proxy()
666 conn_set_state(c, conn_closing); in try_read_command_proxy()
676 assert(cont <= (c->rcurr + c->rbytes)); in try_read_command_proxy()
678 c->last_cmd_time = current_time; in try_read_command_proxy()
679 proxy_process_command(c, c->rcurr, cont - c->rcurr, PROCESS_NORMAL); in try_read_command_proxy()
681 c->rbytes -= (cont - c->rcurr); in try_read_command_proxy()
682 c->rcurr = cont; in try_read_command_proxy()
684 assert(c->rcurr <= (c->rbuf + c->rsize)); in try_read_command_proxy()
692 void proxy_cleanup_conn(conn *c) { in proxy_cleanup_conn() argument
693 assert(c->proxy_rctx); in proxy_cleanup_conn()
694 mcp_rcontext_t *rctx = c->proxy_rctx; in proxy_cleanup_conn()
699 c->proxy_rctx = NULL; in proxy_cleanup_conn()
703 void complete_nread_proxy(conn *c) { in complete_nread_proxy() argument
704 assert(c != NULL); in complete_nread_proxy()
706 LIBEVENT_THREAD *thr = c->thread; in complete_nread_proxy()
709 if (c->proxy_rctx == NULL) { in complete_nread_proxy()
710 complete_nread_ascii(c); in complete_nread_proxy()
714 conn_set_state(c, conn_new_cmd); in complete_nread_proxy()
716 assert(c->proxy_rctx); in complete_nread_proxy()
717 mcp_rcontext_t *rctx = c->proxy_rctx; in complete_nread_proxy()
720 if (strncmp((char *)c->item + rq->pr.vlen - 2, "\r\n", 2) != 0) { in complete_nread_proxy()
724 out_string(c, "CLIENT_ERROR bad data chunk"); in complete_nread_proxy()
733 rq->pr.vbuf = c->item; in complete_nread_proxy()
734 c->item = NULL; in complete_nread_proxy()
735 c->item_malloced = false; in complete_nread_proxy()
736 c->proxy_rctx = NULL; in complete_nread_proxy()
1006 static void proxy_process_command(conn *c, char *command, size_t cmdlen, bool multiget) { in proxy_process_command() argument
1007 assert(c != NULL); in proxy_process_command()
1008 LIBEVENT_THREAD *thr = c->thread; in proxy_process_command()
1021 WSTAT_INCR(c->thread, proxy_conn_errors, 1); in proxy_process_command()
1022 if (!resp_start(c)) { in proxy_process_command()
1023 conn_set_state(c, conn_closing); in proxy_process_command()
1026 proxy_out_errstring(c->resp, PROXY_CLIENT_ERROR, "parsing request"); in proxy_process_command()
1029 conn_set_state(c, conn_closing); in proxy_process_command()
1039 if (c->tag && hook->tagged) { in proxy_process_command()
1042 if (c->tag == pht->tag) { in proxy_process_command()
1064 c->proxy_rctx = NULL; in proxy_process_command()
1065 process_command_ascii(c, command); in proxy_process_command()
1084 if (!resp_start(c)) { in proxy_process_command()
1085 conn_set_state(c, conn_closing); in proxy_process_command()
1088 proxy_out_errstring(c->resp, PROXY_CLIENT_ERROR, "malformed request"); in proxy_process_command()
1090 if (!resp_start(c)) { in proxy_process_command()
1091 conn_set_state(c, conn_closing); in proxy_process_command()
1094 proxy_out_errstring(c->resp, PROXY_CLIENT_ERROR, "key too long"); in proxy_process_command()
1109 proxy_process_command(c, temp, cur - temp, PROCESS_MULTIGET); in proxy_process_command()
1116 if (!resp_start(c)) { in proxy_process_command()
1117 conn_set_state(c, conn_closing); in proxy_process_command()
1125 memcpy(c->resp->wbuf, ENDSTR, ENDLEN); in proxy_process_command()
1126 resp_add_iov(c->resp, c->resp->wbuf, ENDLEN); in proxy_process_command()
1134 WSTAT_INCR(c->thread, proxy_conn_errors, 1); in proxy_process_command()
1135 if (!resp_start(c)) { in proxy_process_command()
1136 conn_set_state(c, conn_closing); in proxy_process_command()
1139 proxy_out_errstring(c->resp, PROXY_CLIENT_ERROR, "request too long"); in proxy_process_command()
1140 conn_set_state(c, conn_closing); in proxy_process_command()
1144 if (!resp_start(c)) { in proxy_process_command()
1145 conn_set_state(c, conn_closing); in proxy_process_command()
1152 struct proxy_int_stats *istats = c->thread->proxy_int_stats; in proxy_process_command()
1154 WSTAT_L(c->thread); in proxy_process_command()
1156 c->thread->stats.proxy_conn_requests++; in proxy_process_command()
1157 active_reqs = c->thread->stats.proxy_req_active; in proxy_process_command()
1158 WSTAT_UL(c->thread); in proxy_process_command()
1161 proxy_out_errstring(c->resp, PROXY_SERVER_ERROR, "active request limit reached"); in proxy_process_command()
1163 c->sbytes = pr.vlen; in proxy_process_command()
1164 conn_set_state(c, conn_swallow); in proxy_process_command()
1172 proxy_out_errstring(c->resp, PROXY_SERVER_ERROR, "lua start failure"); in proxy_process_command()
1174 c->sbytes = pr.vlen; in proxy_process_command()
1175 conn_set_state(c, conn_swallow); in proxy_process_command()
1182 rctx->c = c; in proxy_process_command()
1183 rctx->conn_fd = c->sfd; in proxy_process_command()
1187 rctx->resp = c->resp; in proxy_process_command()
1196 c->item = NULL; in proxy_process_command()
1199 bool oom = proxy_bufmem_checkadd(c->thread, 0); in proxy_process_command()
1203 c->item = malloc(pr.vlen); in proxy_process_command()
1205 if (c->item == NULL) { in proxy_process_command()
1211 proxy_out_errstring(c->resp, PROXY_SERVER_ERROR, "out of memory"); in proxy_process_command()
1212 c->sbytes = pr.vlen; in proxy_process_command()
1213 conn_set_state(c, conn_swallow); in proxy_process_command()
1216 c->item_malloced = true; in proxy_process_command()
1217 c->ritem = c->item; in proxy_process_command()
1218 c->rlbytes = pr.vlen; in proxy_process_command()
1221 c->proxy_rctx = rctx; in proxy_process_command()
1223 conn_set_state(c, conn_nread); in proxy_process_command()
1307 conn *c = rctx->c; in mcp_queue_rctx_io() local
1308 io_queue_t *q = conn_io_queue_get(c, IO_QUEUE_PROXY); in mcp_queue_rctx_io()
1309 io_pending_proxy_t *p = do_cache_alloc(c->thread->io_cache); in mcp_queue_rctx_io()
1311 WSTAT_INCR(c->thread, proxy_conn_oom, 1); in mcp_queue_rctx_io()
1323 p->thread = c->thread; in mcp_queue_rctx_io()
1324 p->c = c; in mcp_queue_rctx_io()