From 186b3f1950788bd6385a965d4c4e691b1af2a3bd Mon Sep 17 00:00:00 2001 From: Marc Worrell Date: Wed, 15 Nov 2023 15:09:30 +0100 Subject: [PATCH] Ensure to use default pool for publishes to (#18) --- src/mqtt_sessions_router.erl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mqtt_sessions_router.erl b/src/mqtt_sessions_router.erl index 8dc41fa..7fb40d3 100644 --- a/src/mqtt_sessions_router.erl +++ b/src/mqtt_sessions_router.erl @@ -88,11 +88,12 @@ publish( Pool, Topic, Msg ) -> -spec publish( atom(), list(), mqtt_packet_map:mqtt_packet(), term() ) -> {ok, pid() | undefined} | {error, overload}. publish( Pool, Topic0, Msg, PublisherContext ) -> Topic = publish_topic(Topic0), - Routes = router:route(Pool, Topic), - case mqtt_sessions_job:publish(Pool, Topic, Routes, Msg, PublisherContext) of + Pool1 = maybe_map_to_default_pool(Pool, Topic), + Routes = router:route(Pool1, Topic), + case mqtt_sessions_job:publish(Pool1, Topic, Routes, Msg, PublisherContext) of {ok, JobPid} -> case maps:get(retain, Msg, false) of - true -> mqtt_sessions_retain:retain(Pool, Msg, PublisherContext); + true -> mqtt_sessions_retain:retain(Pool1, Msg, PublisherContext); false -> ok end, {ok, JobPid};