Handle LIFECYCLE_MSG from traffic_ctl.
| 35 | |
| 36 | /// Handle LIFECYCLE_MSG from traffic_ctl. |
| 37 | static int |
| 38 | global_message_handler(TSCont /* contp ATS_UNUSED */, TSEvent event, void *edata) |
| 39 | { |
| 40 | switch (event) { |
| 41 | case TS_EVENT_LIFECYCLE_MSG: { |
| 42 | TSPluginMsg *msg = static_cast<TSPluginMsg *>(edata); |
| 43 | static constexpr std::string_view PLUGIN_PREFIX("traffic_dump."); |
| 44 | |
| 45 | std::string_view tag(msg->tag, strlen(msg->tag)); |
| 46 | if (tag.substr(0, PLUGIN_PREFIX.size()) == PLUGIN_PREFIX) { |
| 47 | tag.remove_prefix(PLUGIN_PREFIX.size()); |
| 48 | if (tag == "sample" && msg->data_size) { |
| 49 | const auto new_sample_size = static_cast<int64_t>(strtol(static_cast<char const *>(msg->data), nullptr, 0)); |
| 50 | Dbg(dbg_ctl, "TS_EVENT_LIFECYCLE_MSG: Received Msg to change sample size to %" PRId64 "bytes", new_sample_size); |
| 51 | SessionData::set_sample_pool_size(new_sample_size); |
| 52 | } else if (tag == "reset") { |
| 53 | Dbg(dbg_ctl, "TS_EVENT_LIFECYCLE_MSG: Received Msg to reset disk usage counter"); |
| 54 | SessionData::reset_disk_usage(); |
| 55 | } else if (tag == "unlimit") { |
| 56 | Dbg(dbg_ctl, "TS_EVENT_LIFECYCLE_MSG: Received Msg to disable disk usage limit enforcement"); |
| 57 | SessionData::disable_disk_limit_enforcement(); |
| 58 | } else if (tag == "limit" && msg->data_size) { |
| 59 | const auto new_max_disk_usage = static_cast<int64_t>(strtol(static_cast<char const *>(msg->data), nullptr, 0)); |
| 60 | Dbg(dbg_ctl, "TS_EVENT_LIFECYCLE_MSG: Received Msg to change max disk usage to %" PRId64 "bytes", new_max_disk_usage); |
| 61 | SessionData::set_max_disk_usage(new_max_disk_usage); |
| 62 | } |
| 63 | } |
| 64 | return TS_SUCCESS; |
| 65 | } |
| 66 | default: |
| 67 | Dbg(dbg_ctl, "session_aio_handler(): unhandled events %d", event); |
| 68 | return TS_ERROR; |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | } // namespace traffic_dump |
| 73 |
nothing calls this directly
no test coverage detected