通过一系列kernel sock的create bind listen后放入dsper.listen_list,dsper.udp_list
__alloc_serve_sock,create sock object,
sock_create_kern, create kernel socket,
set_sock_callbacks,set callback function,
kernel_setsockopt, set socket alignment type,
if IS_UDP = true, set maximize_sendbuf,
else set kernel_setsockopt socket type is TCP
kernel_bind, kernel_listen, log_socket_port(socket file port and path)
if IS_UDP = true, mc_dispatch_conn_new,create new thread workers for udp servers, then add into udp list,
else add into listen list(tcp list)
mc_conn_work is the final function to r/w mem
mc_worker_machine
sock ->rq ->work ->conn
mc_dispatch_conn_new->mc_conn_new(INIT_WORK(&c->work, mc_conn_work))(shedule by queue_work(c->who->wq, &c->work))
->mc_conn_work->mc_queue_conn->mc_worker_machine
worker_threads(work queue)
摘要:kmemcache是新浪jgli的作品,详见https://github.com/jgli/kmemcache/tree/v0.1_alpha
关键词:kernel memcache netlink callback workqueue
正文:
第一、__kmemcache_bh_init完成memcache的初始化工作,新建thread、sock、workqueue,等待sock连接。
第二、thread的创建以及sock队列的初始化
第三、sock回调函数以及工作队列流程
第四、为什么dispather和server都存在sock,为什么?
mc_sock_work(call by dispatch),server_socket_inet(call by inet);
worker_threads在mc_dispatch_conn_new,存在worker中的sock才会使用worker_threads,所以在dispatcher中应该存在UDP的threads,主要作用就是在init_server中使用。
引用: