moonchen commented on code in PR #13491:
URL: https://github.com/apache/trafficserver/pull/13491#discussion_r3716404906
##########
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 %d 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(new_ProxyMutex()), 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();
+
+ // Until the task threads are registered and spawned, ET_TASK is ET_CALL and
there is nowhere else
+ // to send this.
+ if (ethread == nullptr || ethread->is_event_type(ET_TASK) ||
eventProcessor.thread_group[ET_TASK]._count == 0) {
+ return false;
+ }
+
+ ConfigInfoDestroyer *destroyer = new ConfigInfoDestroyer(id, info);
+
+ if (eventProcessor.schedule_imm(destroyer, ET_TASK) == nullptr) {
+ // The event system is shutting down and will never run the destroyer.
+ delete destroyer;
+ return false;
+ }
+
+ return true;
}
+} // namespace
+
class ConfigInfoReleaser : public Continuation
{
Review Comment:
`ConfigInfoReleaser` is already outside the unnamed namespace on master, so
its linkage is unchanged here:
```c
namespace
{
DbgCtl dbg_ctl_config{"config"};
}
class ConfigInfoReleaser : public Continuation
```
This change moves that closing brace later rather than earlier, so the
namespace now encloses strictly more than it did before. The diff reads as
though a brace were added because the last new line lands immediately above the
pre-existing one, which now closes a function instead of the namespace.
Moving `ConfigInfoReleaser` into the unnamed namespace would be a reasonable
cleanup, but it is pre-existing and unrelated to this change.
--
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]