diff --git a/components/common/cpp/include/ftl/uri.hpp b/components/common/cpp/include/ftl/uri.hpp index 7f549f66a4a8fccd5b8b9eb098088ba604edb3f3..65ac79a97d1f0336f4132e54095a8cc726736b93 100644 --- a/components/common/cpp/include/ftl/uri.hpp +++ b/components/common/cpp/include/ftl/uri.hpp @@ -62,7 +62,8 @@ namespace ftl { template <typename T> T getAttribute(const std::string &key) { - return T(m_qmap[key]); + auto i = m_qmap.find(key); + return (i != m_qmap.end()) ? T(i->second) : T(); } std::string to_string() const; @@ -89,12 +90,14 @@ namespace ftl { template <> inline int URI::getAttribute<int>(const std::string &key) { - return std::stoi(m_qmap[key]); + auto i = m_qmap.find(key); + return (i != m_qmap.end()) ? std::stoi(i->second) : 0; } template <> inline std::string URI::getAttribute<std::string>(const std::string &key) { - return m_qmap[key]; + auto i = m_qmap.find(key); + return (i != m_qmap.end()) ? i->second : ""; } } diff --git a/components/streams/src/feed.cpp b/components/streams/src/feed.cpp index e2215e94603af31c9f16624821778cd62b975bc1..b74385fe99624eda92e776ae8af124cecbc9bd54 100644 --- a/components/streams/src/feed.cpp +++ b/components/streams/src/feed.cpp @@ -396,8 +396,9 @@ ftl::operators::Graph* Feed::_addPipeline(uint32_t fsid) { } void Feed::_createPipeline(uint32_t fsid) { - // FIXME: Must not recreate if already exists - + // Don't recreate if already exists + if (pre_pipelines_.count(fsid)) return; + LOG(INFO) << "Creating pipeline"; auto *p = _addPipeline(fsid); diff --git a/components/streams/src/netstream.cpp b/components/streams/src/netstream.cpp index fba498e1bf03ff96b6760d34b35d33e7896945d5..fe9b7f99f6112e3f0ef392620e9a0c92999295d9 100644 --- a/components/streams/src/netstream.cpp +++ b/components/streams/src/netstream.cpp @@ -252,6 +252,7 @@ bool Net::begin() { set("name", std::string(hostname)); } + active_ = true; net_->broadcast("add_stream", uri_); return true;