Skip to content
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

Feature: TcpServer hot reload SSL file #353

Closed
wants to merge 1 commit into from

Conversation

lizhizhuanshu
Copy link
Contributor

While the TcpServer is running, reload the SSL from the file. New connections will use the new SSL, while existing connections will remain unchanged.

if (policyPtr_) {
sslContextPtr_ = newSSLContext(*policyPtr_, true);
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉应该保证在loop_里执行,check一下是不是当前线程在loop_里,不是的话要queueInLoop一下。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯,我改一下,不过我之前问了,chatgpt,说是在多线程的情况下,引用计数肯定是原子的,至于指针的赋值,可以保证不会出现无意义的数值,但是我也不确定,那就在loop里面吧,这样最少没错误的

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

问题就是引用计数和指针赋值是两步,这两步不是原子的,sslContextPtr_在新连接建立的时候会被读,这是有竞态条件的。

@an-tao an-tao requested a review from marty1885 September 9, 2024 10:42
@lizhizhuanshu lizhizhuanshu deleted the dev branch September 9, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants