From ec76f615851fd6a347cedaeb7b58e585840843f7 Mon Sep 17 00:00:00 2001 From: Samuel Sadok Date: Mon, 11 Jan 2021 16:59:36 +0100 Subject: [PATCH] Squashed 'Firmware/fibre-cpp/' changes from d7049207..11c3c11f 11c3c11f make pyfibre work again git-subtree-dir: Firmware/fibre-cpp git-subtree-split: 11c3c11f25649d2d6da0932b9ecf03436f17d582 --- Dockerfile | 1 + Tupfile.lua | 7 +++++++ fibre.cpp | 16 ++++++++++------ include/fibre/libfibre.h | 7 ++----- libfibre.cpp | 1 + 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 13378bb5..5503ea60 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,6 +55,7 @@ ENV THIRD_PARTY=/ # Set up entrypoint RUN echo "#!/bin/bash" > /entrypoint.sh && \ echo "set -euo pipefail" >> /entrypoint.sh && \ + echo "rm -rdf build/*" >> /entrypoint.sh && \ echo "echo building \$@" >> /entrypoint.sh && \ echo "tup generate --config \$@ /tmp/build.sh" >> /entrypoint.sh && \ echo "exec /usr/bin/bash -x -e /tmp/build.sh" >> /entrypoint.sh && \ diff --git a/Tupfile.lua b/Tupfile.lua index f0575a35..679ca77b 100644 --- a/Tupfile.lua +++ b/Tupfile.lua @@ -135,3 +135,10 @@ if STRIP then outputs={outname} } end + +if string.find(machine, "x86_64.*-apple-.*") then + tup.frule{ + inputs=outname, + command='^c^ chmod 644 %f', + } +end \ No newline at end of file diff --git a/fibre.cpp b/fibre.cpp index a024ec59..2e0d2fa0 100644 --- a/fibre.cpp +++ b/fibre.cpp @@ -125,9 +125,9 @@ Context* fibre::open(EventLoop* event_loop) { auto static_backends_good = for_each_in_tuple(BackendInitializer{ctx}, ctx->static_backends); - // TODO: check static_backends_good - - if (all(static_backends_good)) { + if (!all(static_backends_good)) { + // TODO: shutdown backends + FIBRE_LOG(E) << "some backends failed to initialize"; return nullptr; } @@ -216,8 +216,12 @@ void Domain::start_discovery(Callback on_found_object } void Domain::stop_discovery() { + auto on_lost_object = on_lost_object_; on_found_object_ = nullptr; on_lost_object_ = nullptr; + if (root_object_) { + on_lost_object.invoke(root_object_); + } } #endif @@ -249,14 +253,14 @@ void Domain::on_found_channels(ChannelDiscoveryResult result) { void Domain::on_found_root_object(LegacyObjectClient* obj_client, std::shared_ptr obj) { root_object_ = reinterpret_cast(obj.get()); root_intf_ = reinterpret_cast(obj->intf.get()); - on_found_object_.invoke(reinterpret_cast(obj.get()), - reinterpret_cast(obj->intf.get())); + on_found_object_.invoke(root_object_, root_intf_); } void Domain::on_lost_root_object(LegacyObjectClient* obj_client) { + auto root_object = root_object_; root_object_ = nullptr; root_intf_ = nullptr; - on_lost_object_.invoke(reinterpret_cast(obj_client->root_obj_.get())); + on_lost_object_.invoke(reinterpret_cast(root_object)); } #endif diff --git a/include/fibre/libfibre.h b/include/fibre/libfibre.h index d291334e..091822c3 100644 --- a/include/fibre/libfibre.h +++ b/include/fibre/libfibre.h @@ -423,11 +423,8 @@ FIBRE_PUBLIC void libfibre_subscribe_to_interface(LibFibreInterface* interface, * callback of libfibre_subscribe_to_interface(). * @param child_obj_ptr: If and only if the function succeeds, the variable that * this argument points to is set to the requested subobject. The returned - * object handle is only guaranteed to remain valid until the next - * iteration of the libfibre event loop or until any other libfibre - * function (other than libfibre_ref_obj()) is invoked. If the - * application intends to keep the object handle around it must call - * libfibre_ref_obj() immediately. + * object handle is only guaranteed to remain valid for as long as the + * parent object handle is valid. * @returns: kFibreOk or kFibreInvalidArgument */ FIBRE_PUBLIC LibFibreStatus libfibre_get_attribute(LibFibreObject* parent_obj, LibFibreAttribute* attr, LibFibreObject** child_obj_ptr); diff --git a/libfibre.cpp b/libfibre.cpp index aca8fd25..e7b6d123 100644 --- a/libfibre.cpp +++ b/libfibre.cpp @@ -265,6 +265,7 @@ LibFibreCtx* libfibre_open(LibFibreEventLoop event_loop) { ctx->fibre_ctx = fibre::open(ctx->event_loop); if (!ctx->fibre_ctx) { + FIBRE_LOG(E) << "fibre::open failed"; delete ctx->event_loop; delete ctx; return nullptr;