moonchen commented on code in PR #13491:
URL: https://github.com/apache/trafficserver/pull/13491#discussion_r3723364897
##########
src/iocore/eventsystem/ConfigProcessor.cc:
##########
@@ -34,8 +37,69 @@ namespace
DbgCtl dbg_ctl_config{"config"};
+void
+destroy_config(unsigned int id, ConfigInfo *info)
+{
+ ink_hrtime start = ink_get_hrtime();
+
+ delete info;
+
+ if (dbg_ctl_config.on()) {
+ char thread_name[MAX_THREAD_NAME_LENGTH] = {};
+
+ ink_get_thread_name(thread_name, sizeof(thread_name));
+ DbgPrint(dbg_ctl_config, "Destroyed config %u in %" PRId64 " ns on thread
%s", id, ink_get_hrtime() - start, thread_name);
+ }
+}
+
+/// Runs the destructor of a detached ConfigInfo on ET_TASK.
+class ConfigInfoDestroyer : public Continuation
+{
+public:
+ ConfigInfoDestroyer(unsigned int id, ConfigInfo *info) :
Continuation(nullptr), m_id(id), m_info(info)
+ {
+ SET_HANDLER(&ConfigInfoDestroyer::handle_event);
+ }
+
+ int
+ handle_event(int /* event ATS_UNUSED */, void * /* edata ATS_UNUSED */)
+ {
+ destroy_config(m_id, m_info);
+ delete this;
+ return EVENT_DONE;
+ }
+
+private:
+ unsigned int m_id;
+ ConfigInfo *m_info;
+};
+
+/// Hand a detached ConfigInfo to ET_TASK for destruction. Returns false when
the caller has to
+/// destroy it itself.
+bool
+destroy_config_on_task_thread(unsigned int id, ConfigInfo *info)
+{
+ EThread *ethread = this_ethread();
+
+ // ET_TASK is ET_CALL until the task threads are registered, so before that
point an ET_NET caller
+ // destroys the config on its own thread.
+ if (ethread == nullptr || ethread->is_event_type(ET_TASK)) {
+ return false;
+ }
+
+ ConfigInfoDestroyer *destroyer = new ConfigInfoDestroyer(id, info);
+
+ if (eventProcessor.schedule_imm(destroyer, ET_TASK) == nullptr) {
Review Comment:
If a `ET_TASK` thread doesn't exist, it's a last resort to schedule on
`ET_CALL`. That's expected. I don't think the comment says otherwise.
--
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]