duke8253 commented on code in PR #9323:
URL: https://github.com/apache/trafficserver/pull/9323#discussion_r1090890354
##########
plugins/experimental/stek_share/stek_share.cc:
##########
@@ -57,11 +63,41 @@ shutdown_handler(TSCont contp, TSEvent event, void *edata)
return 0;
}
+static int
+message_handler(TSCont contp, TSEvent event, void *edata)
+{
+ if (event == TS_EVENT_LIFECYCLE_MSG) {
+ TSPluginMsg *msg = static_cast<TSPluginMsg *>(edata);
+ TSDebug(PLUGIN_NAME, "Message to '%s' - %zu bytes of data", msg->tag,
msg->data_size);
+ if ((strnlen(msg->tag, 20) == 10) && (strncmp(msg->tag, PLUGIN_NAME, 10)
== 0)) { // Message is for us
+ if (msg->data_size) {
+ if (strncmp(reinterpret_cast<char *>(const_cast<void *>(msg->data)),
"reload", msg->data_size) == 0) {
+ TSDebug(PLUGIN_NAME, "Reloading configurations...");
+ plugin_threads.terminate();
+ stek_share_server.launcher_.shutdown();
+ if (set_server_info() == 0 &&
init_raft(nuraft::cs_new<STEKShareSM>()) == 0) {
+ TSDebug(PLUGIN_NAME, "Server ID: %d, Endpoint: %s",
stek_share_server.server_id_, stek_share_server.endpoint_.c_str());
+ plugin_threads.reset();
Review Comment:
I'm sure the other threads have actually shut down by this time, since in
the `plugin_threads.terminate()` we have `join` to block it.
```
terminate()
{
shut_down = true;
std::lock_guard<std::mutex> lock(threads_mutex);
while (!threads_queue.empty()) {
pthread_t th = threads_queue.front();
::pthread_join(th, nullptr);
threads_queue.pop_front();
}
}
```
And yes if the updated file has an error it causes a `TSEmergency`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]