Closed lqxhub closed 2 months ago
这次更改涉及多个文件,主要集中在PClient
类的重构、CMake配置的更新、以及事件处理和套接字管理的增强。许多不再使用的功能被注释掉,同时引入了新的库和头文件。类的构造函数和成员函数进行了调整,并新增了命名空间以优化代码组织。整体结构更加清晰,异步处理能力得到了提升。
文件路径 | 更改摘要 |
---|---|
CMakeLists.txt | 添加-Wno-restrict标志,移除libevent.cmake,添加llhttp.cmake |
src/client.cc, .h | 修改和注释掉PClient类中与数据包处理和连接管理相关的代码 |
src/cmd_raft.cc | 注释掉对"net/event_loop.h"的包含 |
src/cmd_thread_pool.h | 将CmdThreadPoolTask的构造函数改为显式 |
src/common.h | 包含"unbounded_buffer.h",注释掉UnboundedBuffer类的声明 |
src/config.h | 修改包含文件路径 |
src/config_parser.cc, .h | 将ConfigParser类包裹在pikiwidb命名空间中 |
src/io_thread_pool.cc, .h | 注释掉IOThreadPool和WorkIOThreadPool类及其成员方法 |
src/net/CMakeLists.txt | 更新CMake配置,设置C++标准为20,调整库链接 |
src/net/base_event.h | 添加BaseEvent类及其构造函数、虚函数和成员函数 |
src/net/base_socket.cc, .h | 增强BaseSocket类,增加多种套接字操作方法 |
src/net/callback_function.h | 引入与网络事件处理相关的概念和函数 |
src/net/client_socket.cc, .h | 扩展ClientSocket类,添加连接方法和失败回调函数 |
src/net/config.h | 引入条件编译指令,定义平台特定宏 |
src/net/epoll_event.cc, .h | 添加EpollEvent类,处理epoll事件,包括初始化、添加、删除和轮询 |
src/net/kqueue_event.cc | 引入KqueueEvent类,实现Kqueue事件处理系统 |
代码如歌,蜕变如舞,
连接处理,更加稳固。
事件流转,轻松自如,
编译配置,焕然一新。
代码的兔子,欢快跳跃,
迎接变化,无畏无惧。
🐇✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
@Tangruilin
Bot detected the issue body's language is not English, translate it automatically.
@Tangruilin
我在本地跑了一下,好像建立客户端连接后输出的信息没有处理好
client 退出会引起 Segmentation fault: 11
原因是使用了空指针
先 close 后 erase
不再报错
Bot detected the issue body's language is not English, translate it automatically.
Client exit will cause Segmentation fault: 11
The reason is the use of a null pointer
问题
client 退出会引起 Segmentation fault: 11
原因是使用了空指针
修复
先 close 后 erase
不再报错 多谢, 万万没想到是这里的问题😅
Bot detected the issue body's language is not English, translate it automatically.
问题
client 退出会引起 Segmentation fault: 11 ![image](https://private-user-images.githubusercontent.com/20750625/346613809-6c44d8f4-29b1-4b39-8b09-279e24c5d0ca.png?jwt=eyJhbGci OiJIUzI1NiIsInR5cCI6IkpXVCJ9..XqfX6ECiOw9LDV0VeqWkaQ6N9jABmOHmNQAxb3Uv5sc )
原因是使用了空指针 ![image](https://private-user-images.githubusercontent.com/20750625/346613756-65d575f3-2adc-47de-a3b9-608ebf124c4e.png?jwt=eyJhbGciO iJIUzI1NiIsInR5cCI6IkpXVCJ9..amBxf5kyt9f_LYifz1O5-HorwB6Wpu -IT4OoKyXACXI)
修复
先 close 后 erase ![image](https://private-user-images.githubusercontent.com/20750625/346616801-2803949f-e647-4e2f-9ea5-1d6b703cbb09.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6 IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0ODY3NzgsIm5iZiI6MTcyMDQ4NjQ3OCwicGF0aCI 6Ii8yMDc1MDYyNS8zNDY2MTY4MDEtMjgwMzk0OWYtZTY0Ny00ZTJmLTllYTUtMWQ2YjcwM2NiYjA5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50a WFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDAwNTQzOFomWC1BbXotRXhwaXJlcz0zMDAm WC1BbXotU2lnbmF0dXJlPTNlMjU0YzEwOWNjZmExYTU3ZTJkNTQ1YjcxMDBhMTRkZjFmODc4YmUyZDBhZTE0ZTkxNDQ5NjYxOGQ0YTc3ZmEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0 JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.wTBZlaLxb8qciuipioMpJnAXOhvy2Dg5cK-RkOSlkxY)
不再报错 ![image](https://private-user-images.githubusercontent.com/20750625/346616615-7cc2f977-8bfa-42cd-a5d0-6ba38f883219.png?jwt=eyJhbGciOiJIUzI1NiIsInR5 cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjA0ODY3NzgsIm5iZiI6MTcyMDQ4NjQ3OCwicGF 0aCI6Ii8yMDc1MDYyNS8zNDY2MTY2MTUtN2NjMmY5NzctOGJmYS00MmNkLWE1ZDAtNmJhMzhmODgzMjE5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW5 0aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzA5VDAwNTQzOFomWC1BbXotRXhwaXJlcz0zMD AmWC1BbXotU2lnbmF0dXJlPTJhNTBhZWY4NWQxZTA0NTI0ZTI0YzdkZWFhMDAzMWU1OTYyYjMyOTdlZGU3Mjg0NDZjYTk2NjdkZDZjNDA5Y2MmWC1BbXotU2lnbmVkSGVhZGVycz1ob3 N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.8RaGl84DWLhypqWCuJWugFgl5bHYu7xwPuoNTvPPX3w) 多谢, 万万没想到是这里的问题😅
还没处理完,go test时还有问题,我继续看下
Bot detected the issue body's language is not English, translate it automatically.
It's not finished yet. There are still problems during go test. I'll continue to look at it.
去掉libevent依赖, 重写网络库, 目前检查format还有问题, 等明天有时间再看
还有两个地方可能是有风险的
fd
作为了 client的唯一IDPClient
如果修改了, 可能导致 初始化失败. https://github.com/OpenAtomFoundation/pikiwidb/pull/349/files#diff-2fe737c7212297d7ce5a3812df52450f0af5dacb22954ff20bd3acd673fc5954R31-R47Summary by CodeRabbit
新功能
KqueueEvent
类,提供基于 Kqueue 的事件处理系统,提升网络连接的异步I/O操作效率。BaseEvent
和EpollEvent
类,增强事件和套接字管理功能。ClientSocket
类,添加了Connect
方法以建立非阻塞TCP连接。UnboundedBuffer
类新增了ToString()
方法,方便获取和清空缓冲区内容。ListenSocket
类,用于处理传入连接。文档
CMakeLists.txt
,设置了C++标准为20,调整项目配置。重构
src/config_parser.cc
和src/config_parser.h
中引入了pikiwidb
命名空间,组织代码结构。CmdThreadPoolTask
类的构造函数,使其为explicit
。样式
杂项
config.h
文件中引入了平台特定的宏定义。