MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / remove_log_subscription

Method remove_log_subscription

src/log/log-service.cpp:579–630  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577
578
579void ServiceHandler::remove_log_subscription(LogTag::Ptr tag,
580 pid_t pid,
581 LogMetaData::Ptr meta)
582{
583 if (!tag)
584 {
585 return;
586 };
587
588 // It is needed to remove the {session path, interface} -> log tag hash
589 // lookup index entry. But the only available information is the log tag
590 // hash. One way to solve this is to do a "reverse lookup", by looking
591 // up the log tag hash value instead. That gives us the iterator entry
592 // which can be used to remove the entry from the index.
593 size_t tag_hash = tag->hash;
594 auto sesstag_idx = std::find_if(session_logtag_index.begin(),
595 session_logtag_index.end(),
596 [tag_hash](const auto &element)
597 {
598 return element.second == tag_hash;
599 });
600 if (session_logtag_index.end() != sesstag_idx)
601 {
602 session_logtag_index.erase(sesstag_idx);
603 }
604
605 // Remove the AttachedService element, which will unsubscribe the
606 // Log + StatusChange signals for this sender
607 log_attach_subscr.at(tag->hash).reset();
608 log_attach_subscr.erase(tag->hash);
609
610 std::ostringstream msg;
611 msg << "Detached: " << *tag << " " << tag->tag;
612 if (0 < pid)
613 {
614 msg << ", pid " << std::to_string(pid);
615 }
616 log->LogVerb2(msg.str(), meta);
617
618 if (log_attach_subscr.size() < 1)
619 {
620 // In method_attach(), the idle detector check was re-enabled for
621 // this ServiceHandler object when the Attach() method completed
622 // successfully. This was done to avoid this log service to idle
623 // exit even though external services still had attached their
624 // logging to this service. When there are no more services
625 // attached, this idle check logic can be re-enabled, where the
626 // presence of this ServiceHandler object should no longer be
627 // considered in the idle check.
628 DisableIdleDetector(true);
629 }
630}
631
632
633const bool ServiceHandler::check_detach_access(LogTag::Ptr tag,

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.80
resetMethod · 0.45
LogVerb2Method · 0.45
strMethod · 0.45

Tested by

no test coverage detected