-
Notifications
You must be signed in to change notification settings - Fork 120
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
support reset photon at fork #282
Conversation
3c2c6e5
to
3090204
Compare
3090204
to
a24cd48
Compare
io/reset_handle.cpp
Outdated
|
||
namespace photon { | ||
|
||
static ResetHandle *&ree_list() { |
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.
it seems no need to hide the list inside a function
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.
outter function has been removed.
io/reset_handle.cpp
Outdated
namespace photon { | ||
|
||
static ResetHandle *&ree_list() { | ||
static thread_local ResetHandle *list = nullptr; |
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.
better use intrusive_list<ResetHandle> list;
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.
using pointer is meant to avoid construct/destruct.
io/reset_handle.cpp
Outdated
} | ||
|
||
void reset_all_handle() { | ||
if (ree_list() == nullptr) |
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.
will be no need to handle nullptr, when using intrusive_list<ResetHandle>
thread_yield(); // give a chance let eloop to execute do_wait | ||
pthread_atfork(nullptr, nullptr, &fork_hook_child); | ||
if (reset_handler == nullptr) { | ||
reset_handler = new SignalResetHandle(); |
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.
better hide a handler object inside a function, rather than new one
@@ -240,6 +254,10 @@ int libcurl_init(long flags, long pipelining, long maxconn) { | |||
|
|||
libcurl_set_pipelining(pipelining); | |||
libcurl_set_maxconnects(maxconn); | |||
if (reset_handler == nullptr) { | |||
reset_handler = new CurlResetHandle(); |
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.
better hide the handlers inside a function
return 0; | ||
} | ||
}; | ||
static thread_local CurlResetHandle *reset_handler = nullptr; |
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.
better hide the handlers inside a function like this:
static CurlResetHandle* get_reset_handler() {
static thread_local unique_ptr<CurlResetHandle> handler { new CurlResetHandle};
return handler.get();
}
And there's no need to destruct it explicitly.
The same for aio, etc.
In photon context, event engine based module need reset after fork, if exec will not be called after fork. This is implicitly done by pthread_atfork hook. Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com>
a24cd48
to
882db3f
Compare
* Mute an UBSan check error for SCOPED_LOCK macro (#283) * io: support reset photon at fork (#282) In photon context, event engine based module need reset after fork, if exec will not be called after fork. This is implicitly done by pthread_atfork hook. Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> --------- Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> Co-authored-by: Bob Chen <beef9999@qq.com> Co-authored-by: yuchen0cc <91253032+yuchen0cc@users.noreply.github.com>
* Mute an UBSan check error for SCOPED_LOCK macro (#283) * io: support reset photon at fork (#282) In photon context, event engine based module need reset after fork, if exec will not be called after fork. This is implicitly done by pthread_atfork hook. Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * RPC support graceful shutdown --------- Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> Co-authored-by: Bob Chen <beef9999@qq.com> Co-authored-by: yuchen0cc <91253032+yuchen0cc@users.noreply.github.com>
* Mute an UBSan check error for SCOPED_LOCK macro (#283) * io: support reset photon at fork (#282) In photon context, event engine based module need reset after fork, if exec will not be called after fork. This is implicitly done by pthread_atfork hook. Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * RPC support graceful shutdown * fs: support xattr for extfs and subfs (#298) Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * Sequential mutex (#294) seq_mutex * exit(0) requires stdlib.h (#303) * fix e2fs include dir name (#301) Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * [feat] http client with cert Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> --------- Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> Co-authored-by: Bob Chen <beef9999@qq.com> Co-authored-by: yuchen0cc <91253032+yuchen0cc@users.noreply.github.com> Co-authored-by: Huiba Li <lihuiba@gmail.com> Co-authored-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> Co-authored-by: Lanzheng Liu <lanzheng.liulz@alibaba-inc.com>
* Mute an UBSan check error for SCOPED_LOCK macro (#283) * io: support reset photon at fork (#282) In photon context, event engine based module need reset after fork, if exec will not be called after fork. This is implicitly done by pthread_atfork hook. Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * RPC support graceful shutdown * fs: support xattr for extfs and subfs (#298) Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * Sequential mutex (#294) seq_mutex * exit(0) requires stdlib.h (#303) * fix e2fs include dir name (#301) Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> * [feat] http client with cert Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> * minor fix for std-compat (#307) * minor fix for std-compat * rpc::string add empty method * set io_uring eventfd non-blocking --------- Signed-off-by: yuchen.cc <yuchen.cc@alibaba-inc.com> Signed-off-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> Co-authored-by: Bob Chen <beef9999@qq.com> Co-authored-by: yuchen0cc <91253032+yuchen0cc@users.noreply.github.com> Co-authored-by: Huiba Li <lihuiba@gmail.com> Co-authored-by: zhuangbowei.zbw <zhuangbowei.zbw@alibaba-inc.com> Co-authored-by: Lanzheng Liu <lanzheng.liulz@alibaba-inc.com>
In photon context, event engine based module need reset after fork, if exec will not be called after fork.
This is implicitly done by pthread_atfork hook.