From c7d6505470a0df900ebba8ab0c4b9a3a5f474d93 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nicolas.pope@utu.fi>
Date: Wed, 7 Sep 2022 15:06:08 +0100
Subject: [PATCH] Fix compile in gcc 11, URI exceptions

---
 include/ftl/codec/msgpack.hpp | 4 +++-
 src/streams/muxer.cpp         | 1 +
 src/uri.cpp                   | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/ftl/codec/msgpack.hpp b/include/ftl/codec/msgpack.hpp
index 4f8eba9..b211b0d 100644
--- a/include/ftl/codec/msgpack.hpp
+++ b/include/ftl/codec/msgpack.hpp
@@ -6,7 +6,9 @@
 
 template <typename T>
 void ftl::codec::pack(const T &v, std::vector<uint8_t> &out) {
-    out.resize(0);
+    // Note: The following breaks in gcc 11 and 12.
+    //out.resize(0);
+    //out.reserve(1024);
     ftl::util::FTLVectorBuffer buf(out);
     msgpack::pack(buf, v);
 }
diff --git a/src/streams/muxer.cpp b/src/streams/muxer.cpp
index b0f6b57..a5b425e 100644
--- a/src/streams/muxer.cpp
+++ b/src/streams/muxer.cpp
@@ -22,6 +22,7 @@ Muxer::~Muxer() {
         se.handle.cancel();
         se.req_handle.cancel();
         se.avail_handle.cancel();
+        se.err_handle.cancel();
     }
 }
 
diff --git a/src/uri.cpp b/src/uri.cpp
index a0310b8..7bb463b 100644
--- a/src/uri.cpp
+++ b/src/uri.cpp
@@ -38,7 +38,7 @@ static const std::unordered_map<std::string, ftl::URI::scheme_t> schemeMap = {
     {"device", URI::SCHEME_DEVICE},
     {"file", URI::SCHEME_FILE},
     {"group", URI::SCHEME_GROUP},
-    {"beyond", URI::SCHEME_TCP},
+    {"beyond", URI::SCHEME_BEYOND},
     {"mux", URI::SCHEME_MUX},
     {"mirror", URI::SCHEME_MIRROR},
     {"cast", URI::SCHEME_CAST}
@@ -136,7 +136,7 @@ void URI::_parse(uri_t puri) {
 
         std::string porttext = std::string(uri.portText.first, uri.portText.afterLast - uri.portText.first);
         try {
-            m_port = std::stoi(porttext);
+            m_port = (porttext.size() > 0) ? std::stoi(porttext) : 0;
             if (m_port < 0 || m_port >= 65535) {
                 throw FTL_Error("Port out of range");
             }
-- 
GitLab