-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: init every class member's value to defeat the redis-cli connection closed by pika #1390
fix: init every class member's value to defeat the redis-cli connection closed by pika #1390
Conversation
is ready? |
af131bd
to
436647e
Compare
@@ -76,30 +78,36 @@ class NetConn : public std::enable_shared_from_this<NetConn> { | |||
|
|||
NetMultiplexer* net_multiplexer() const { return net_multiplexer_; } | |||
|
|||
std::string String() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToString
@@ -20,13 +20,16 @@ class NetItem { | |||
|
|||
int fd() const { return fd_; } | |||
std::string ip_port() const { return ip_port_; } | |||
std::string String() const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToString
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToString
我这个是借鉴 Go 的实现,ToString() 是 Java 的吗?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
额接口名字而已,String也行,别的库基本都是ToString ToStringView to_string to_stringview 这几类
@loveyacper Pls check it again. thx. |
…on closed by pika (OpenAtomFoundation#1390) * update version * fix bug: wrong buffer size in vsnprintf * fix holyThread close fd bug * handle ewouldblock error * add output macro * init NetConn & RedisConn & ClientConn members' value in its class * delete output macro * delete ks.sh * reformat output macro * init NetConn & RedisConn & ClientConn members' value in its class * add connection log * recove GetTestDirectory * do not init non-POD obj
…on closed by pika (OpenAtomFoundation#1390) * update version * fix bug: wrong buffer size in vsnprintf * fix holyThread close fd bug * handle ewouldblock error * add output macro * init NetConn & RedisConn & ClientConn members' value in its class * delete output macro * delete ks.sh * reformat output macro * init NetConn & RedisConn & ClientConn members' value in its class * add connection log * recove GetTestDirectory * do not init non-POD obj
fix #1367 : server 与 client 之间间歇性断开问题 https:/OpenAtomFoundation/pika/issues/1367#issuecomment-1518607186。
问题代码所在:
这里构造函数,没见啥地方初始化 close_ 字段的值,但是它的值为 true。原因就在于 C++ 中如果不给变量初始化值,其值未定义,为 true 还是为 false 都有可能。
解决方法:在 class 中初始化成员变量的值。