From: Lukasz Czarnik -X (lczarnik - SOFTSERVE INC at Cisco) Date: Tue, 26 Mar 2024 18:54:26 +0000 (+0000) Subject: Pull request #4254: appid: separate main thread and packet thread appid_pub_id X-Git-Tag: 3.1.84.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c6a60a04509b44ece5dead1d4a9638280827f92;p=thirdparty%2Fsnort3.git Pull request #4254: appid: separate main thread and packet thread appid_pub_id Merge in SNORT/snort3 from ~LCZARNIK/snort3:appid_pub_id to master Squashed commit of the following: commit c7e9539db79ad120fdd1c50dd2b1d213378e6aa9 Author: Lukasz Czarnik Date: Fri Mar 22 07:53:34 2024 -0400 appid: separate main thread and packet thread appid_pub_id --- diff --git a/src/network_inspectors/appid/appid_inspector.cc b/src/network_inspectors/appid/appid_inspector.cc index c98004d5a..ea17d1562 100644 --- a/src/network_inspectors/appid/appid_inspector.cc +++ b/src/network_inspectors/appid/appid_inspector.cc @@ -66,7 +66,8 @@ THREAD_LOCAL ThirdPartyAppIdContext* pkt_thread_tp_appid_ctxt = nullptr; THREAD_LOCAL OdpThreadContext* odp_thread_local_ctxt = nullptr; THREAD_LOCAL OdpContext* pkt_thread_odp_ctxt = nullptr; -unsigned AppIdInspector::pub_id = 0; +unsigned AppIdInspector::cached_global_pub_id = 0; +static THREAD_LOCAL unsigned appid_pub_id = 0; static THREAD_LOCAL PacketTracer::TracerMute appid_mute; @@ -111,6 +112,10 @@ AppIdContext& AppIdInspector::get_ctxt() const assert(ctxt); return *ctxt; } +unsigned AppIdInspector::get_pub_id() +{ + return appid_pub_id; +} bool AppIdInspector::configure(SnortConfig* sc) { @@ -167,7 +172,8 @@ bool AppIdInspector::configure(SnortConfig* sc) DataBus::subscribe_global(intrinsic_pub_key, IntrinsicEventIds::FLOW_NO_SERVICE, new AppIdServiceEventHandler(*this), *sc); - pub_id = DataBus::get_id(appid_pub_key); + cached_global_pub_id = DataBus::get_id(appid_pub_key); + appid_pub_id = cached_global_pub_id; return true; } @@ -178,6 +184,7 @@ void AppIdInspector::show(const SnortConfig*) const void AppIdInspector::tinit() { + appid_pub_id = cached_global_pub_id; appid_mute = PacketTracer::get_mute(); AppIdStatistics::initialize_manager(*config); diff --git a/src/network_inspectors/appid/appid_inspector.h b/src/network_inspectors/appid/appid_inspector.h index 9a19c735e..d2928b392 100644 --- a/src/network_inspectors/appid/appid_inspector.h +++ b/src/network_inspectors/appid/appid_inspector.h @@ -49,12 +49,12 @@ public: AppIdContext& get_ctxt() const; const AppIdConfig& get_config() const { return *config; } - static unsigned get_pub_id() { return pub_id; } + static unsigned get_pub_id(); private: const AppIdConfig* config = nullptr; AppIdContext* ctxt = nullptr; - static unsigned pub_id; + static unsigned cached_global_pub_id; }; extern const snort::InspectApi appid_inspector_api;