ZLMediaKit / ZLToolKit

一个基于C++11的轻量级网络框架,基于线程池技术可以实现大并发网络IO
MIT License
1.88k stars 572 forks source link

缓冲区大小cmake定义, 增加Err_reset错误 #196

Closed alexliyu7352 closed 7 months ago

alexliyu7352 commented 7 months ago

The default buffer size of a socket should not be hardcoded in the program; it should be configurable. Additionally, in Linux, adjusting kernel parameters can be more effective in improving the performance or throughput of a program in scenarios such as high-latency "long fat networks" or high-concurrency situations, compared to using setsockopt.

  1. 可以在cmake中定义默认缓冲区大小, 当为0时内核调解缓冲区大小.
  2. 捕捉UV_ECONNRESET错误, zlm的httpclient默认使用持久化链接, 部分服务器有通过webserver或者firewall设置了连接空闲时间时会触发UV_ECONNRESET.
xia-chu commented 7 months ago

感觉你的改法有点绕啊,有没有必要改成这样:

#if !defined(SOCKET_DEFAULT_BUF_SIZE)
#define SOCKET_DEFAULT_BUF_SIZE 256 * 1024
#endif
if(DEFINED SOCKET_DEFAULT_BUF_SIZE)
    add_definitions(-DSOCKET_DEFAULT_BUF_SIZE=${SOCKET_DEFAULT_BUF_SIZE})
endif()

就是在cmake中不指定宏 就默认设置下。

alexliyu7352 commented 7 months ago

感觉你的改法有点绕啊,有没有必要改成这样:

#if !defined(SOCKET_DEFAULT_BUF_SIZE)
#define SOCKET_DEFAULT_BUF_SIZE 256 * 1024
#endif
if(DEFINED SOCKET_DEFAULT_BUF_SIZE)
    add_definitions(-DSOCKET_DEFAULT_BUF_SIZE=${SOCKET_DEFAULT_BUF_SIZE})
endif()

就是在cmake中不指定宏 就默认设置下。

的确哦, 这是很早之前的, 我是从之前项目直接复制过来了, 抱歉哈... 我改改