首页 > 代码库 > twemproxy源码分析之五:zero copy
twemproxy源码分析之五:zero copy
先给出msg的数据结构:
truct msg { TAILQ_ENTRY(msg) c_tqe; TAILQ_ENTRY(msg) s_tqe; TAILQ_ENTRY(msg) m_tqe; uint64_t id; int route_idx; struct msg *peer; struct conn *owner; struct rbnode tmo_rbe; struct mhdr mhdr; uint32_t mlen; int state; uint8_t *pos; uint8_t *token; msg_parse_t parser; msg_parse_result_t result; mbuf_copy_t pre_splitcopy; msg_post_splitcopy_t post_splitcopy; msg_coalesce_t pre_coalesce; msg_coalesce_t post_coalesce; msg_type_t type; uint8_t *key_start; uint8_t *key_end; uint32_t vlen; uint8_t *end; uint8_t *narg_start; uint8_t *narg_end; uint32_t narg; uint32_t rnarg; uint32_t rlen; uint32_t integer; struct msg *frag_owner; uint32_t nfrag; uint64_t frag_id; err_t err; unsigned error:1; unsigned ferror:1; unsigned request:1; unsigned quit:1; unsigned noreply:1; unsigned done:1; unsigned fdone:1; unsigned first_fragment:1; unsigned last_fragment:1; unsigned swallow:1; unsigned redis:1; |
看这三个成员
TAILQ_ENTRY(msg) c_tqe;
TAILQ_ENTRY(msg) s_tqe;
TAILQ_ENTRY(msg) m_tqe;
c_tqe是用来插入到client类型的conn中的输入或者输出队列中
s_tqe是用来插入到server类型的conn(即连接后端redis server的conn)中的输入或者输出队列中
m_tqe是用来插入到发送对列(一个发送队列对应一个远端或是client或是redisinstance)中的输入或者输出队列中
具体的插入删除过程见上一篇。
twemproxy源码分析之五:zero copy
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。