摘要: mesh结构 msg_cache + rr_cache缓存数据 msg_cache里的entry是msgreply_entry,rr_cache里的entry是ub_packed_rrset_key。 ub_packed_rrset_key的rrset_id_type通过alloc_get_id方法 阅读全文
posted @ 2024-11-05 00:06 yghr 阅读(76) 评论(0) 推荐(0)
摘要: unbound入口在run_daemon方法。 daemon_init方法,分配struct daemon结构体,设置信号处理方法,初始化openssl库,设置时区,设置daemon->need_to_exit为0,初始化模块栈(modstack_init方法)设置deamon->mods结构体(s 阅读全文
posted @ 2024-11-05 00:04 yghr 阅读(182) 评论(0) 推荐(0)
摘要: 在一个pthread_once方法内又再次调用了这个pthread_once导致死锁。 分析下这个pthread_once的源码: 可以看到这个pthread_once_t结构体就是一个整形数字加自旋锁。 int ___pthread_once (pthread_once_t *once_contr 阅读全文
posted @ 2024-08-06 23:46 yghr 阅读(141) 评论(0) 推荐(0)
摘要: gcc函数调用 进入一个函数后的栈布局 /* + + | 第6个参数后的参数(如果有) | + + | 返回地址(调用函数的下一个指令)| + + | 上一个函数rbp | + + | 当前函数局部变量 | + + */ makecontext方法实现 void __makecontext (uco 阅读全文
posted @ 2024-07-31 23:40 yghr 阅读(128) 评论(0) 推荐(0)
摘要: unbound可以通过配置文件中的cache-max-ttl来设置缓存的最大缓存时间,这个会保存MAX_TTL全局变量(默认值是10天)。 unbound在处理递归响应时的调用链是comm_point_udp_callback -> outnet_udp_cb -> serviced_udp_cal 阅读全文
posted @ 2024-06-14 01:09 yghr 阅读(213) 评论(0) 推荐(0)
摘要: 对进程进行采集,采集后会在当前目录下生成一个perf.data文件 perf record -e cpu-clock --call-graph dwarf [-t 线程id] [-p 进程id] 这里只针对cpu时间进行了采样,通过perf list命令还可以看到更多采样事件。 简单分析 perf 阅读全文
posted @ 2024-06-09 19:18 yghr 阅读(123) 评论(0) 推荐(0)
摘要: localtime方法会加锁,当TZ环境变量为空或者变更时,还会读取文件,还有个问题就是这个方法返回的指针是一个全局变量,可以使用redis无锁的localtime方法来优化这个性能。 localtime方法调用链:localtime -> __localtime64 -> __tz_convert 阅读全文
posted @ 2024-06-09 19:05 yghr 阅读(458) 评论(0) 推荐(0)
摘要: redis 5.0 命令处理流程 初始化事件驱动数据结构: initServer 中调用 aeCreateEventLoop 方法初始化 server.el 属性,然后调用 listenToPort 方法设置 listen 的 fd,并为这些 fd 绑定读事件 anetTcpHandler。 ane 阅读全文
posted @ 2024-03-31 22:46 yghr 阅读(64) 评论(0) 推荐(0)
摘要: unbound源码分析 版本: 1.17.2 编译选项: ./configure --prefix=your_path --enable-subnet --enable-debug --with-libevent 请求调用栈: 看了worker_handle_request的源码,unbound也是 阅读全文
posted @ 2024-03-31 20:27 yghr 阅读(287) 评论(0) 推荐(0)
摘要: 在集群模式下,如果lua脚本同时操作多个key,可能会出现:CROSSSLOT Keys in request don't hash to the same slot的错误。 这种情况下,可以通过{...},来指定多个key使用相同的内容进行hash,例如:user:{123}:username和u 阅读全文
posted @ 2023-12-18 15:15 yghr 阅读(243) 评论(0) 推荐(0)