diff options
author | David Robillard <d@drobilla.net> | 2012-06-29 23:06:19 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-06-29 23:06:19 +0000 |
commit | 8f7f419adcfcd6cd7557b82266b064ed242793ad (patch) | |
tree | e0004f6eec4958260df53c711ac2c92d85e8f4cc | |
parent | 6eb584d3b0bc67fc8de36baba5e296d816ba080f (diff) | |
download | ingen-8f7f419adcfcd6cd7557b82266b064ed242793ad.tar.gz ingen-8f7f419adcfcd6cd7557b82266b064ed242793ad.tar.bz2 ingen-8f7f419adcfcd6cd7557b82266b064ed242793ad.zip |
Fix crashes caused by events attempting to respond to deleted clients (fix #842).
This one mainly manifested when using ingenish from the command line since the client is so short lived.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4503 a436a847-0d15-0410-975c-d299462d15a1
25 files changed, 114 insertions, 114 deletions
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index c5a7bddd..85ca530c 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -218,8 +218,9 @@ Engine::activate() make_pair(uris.ingen_canvasY, Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); + SharedPtr<Interface> respondee; execute_and_delete_event( - context, new Events::CreatePort(*this, NULL, -1, 0, + context, new Events::CreatePort(*this, respondee, -1, 0, "/control_in", false, in_properties)); // Add control out @@ -236,7 +237,7 @@ Engine::activate() Resource::Property(forge.make(32.0f), Resource::EXTERNAL))); execute_and_delete_event( - context, new Events::CreatePort(*this, NULL, -1, 0, + context, new Events::CreatePort(*this, respondee, -1, 0, "/control_out", true, out_properties)); } diff --git a/src/server/Event.hpp b/src/server/Event.hpp index 6820e8e2..963671ab 100644 --- a/src/server/Event.hpp +++ b/src/server/Event.hpp @@ -86,7 +86,7 @@ public: } protected: - Event(Engine& engine, Interface* client, int32_t id, FrameTime time) + Event(Engine& engine, SharedPtr<Interface> client, int32_t id, FrameTime time) : _engine(engine) , _request_client(client) , _request_id(id) @@ -97,7 +97,6 @@ protected: /** Constructor for internal events only */ explicit Event(Engine& engine) : _engine(engine) - , _request_client(NULL) , _request_id(-1) , _time(0) , _status(NOT_PREPARED) @@ -110,7 +109,7 @@ protected: Engine& _engine; Raul::AtomicPtr<Event> _next; - Interface* _request_client; + SharedPtr<Interface> _request_client; int32_t _request_id; FrameTime _time; Status _status; diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp index f0a2f100..43cf25ac 100644 --- a/src/server/EventWriter.cpp +++ b/src/server/EventWriter.cpp @@ -55,7 +55,7 @@ EventWriter::put(const Raul::URI& uri, const Resource::Graph ctx) { _engine.enqueue_event( - new Events::Delta(_engine, _respondee.get(), _request_id, now(), + new Events::Delta(_engine, _respondee, _request_id, now(), true, ctx, uri, properties)); } @@ -65,7 +65,7 @@ EventWriter::delta(const Raul::URI& uri, const Resource::Properties& add) { _engine.enqueue_event( - new Events::Delta(_engine, _respondee.get(), _request_id, now(), + new Events::Delta(_engine, _respondee, _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } @@ -74,7 +74,7 @@ EventWriter::move(const Raul::Path& old_path, const Raul::Path& new_path) { _engine.enqueue_event( - new Events::Move(_engine, _respondee.get(), _request_id, now(), + new Events::Move(_engine, _respondee, _request_id, now(), old_path, new_path)); } @@ -82,7 +82,7 @@ void EventWriter::del(const Raul::URI& uri) { _engine.enqueue_event( - new Events::Delete(_engine, _respondee.get(), _request_id, now(), uri)); + new Events::Delete(_engine, _respondee, _request_id, now(), uri)); } void @@ -90,7 +90,7 @@ EventWriter::connect(const Raul::Path& tail_path, const Raul::Path& head_path) { _engine.enqueue_event( - new Events::Connect(_engine, _respondee.get(), _request_id, now(), + new Events::Connect(_engine, _respondee, _request_id, now(), tail_path, head_path)); } @@ -100,7 +100,7 @@ EventWriter::disconnect(const Raul::Path& src, const Raul::Path& dst) { _engine.enqueue_event( - new Events::Disconnect(_engine, _respondee.get(), _request_id, now(), + new Events::Disconnect(_engine, _respondee, _request_id, now(), src, dst)); } @@ -109,7 +109,7 @@ EventWriter::disconnect_all(const Raul::Path& patch_path, const Raul::Path& path) { _engine.enqueue_event( - new Events::DisconnectAll(_engine, _respondee.get(), _request_id, now(), + new Events::DisconnectAll(_engine, _respondee, _request_id, now(), patch_path, path)); } @@ -123,7 +123,7 @@ EventWriter::set_property(const Raul::URI& uri, Resource::Properties add; add.insert(make_pair(predicate, value)); _engine.enqueue_event( - new Events::Delta(_engine, _respondee.get(), _request_id, now(), + new Events::Delta(_engine, _respondee, _request_id, now(), false, Resource::DEFAULT, uri, add, remove)); } @@ -131,7 +131,7 @@ void EventWriter::get(const Raul::URI& uri) { _engine.enqueue_event( - new Events::Get(_engine, _respondee.get(), _request_id, now(), uri)); + new Events::Get(_engine, _respondee, _request_id, now(), uri)); } } // namespace Server diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index d4df3e68..b9ea148a 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -34,12 +34,12 @@ namespace Ingen { namespace Server { namespace Events { -Connect::Connect(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& tail_path, - const Raul::Path& head_path) +Connect::Connect(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& tail_path, + const Raul::Path& head_path) : Event(engine, client, id, timestamp) , _tail_path(tail_path) , _head_path(head_path) diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp index a4bad5e8..87de6104 100644 --- a/src/server/events/Connect.hpp +++ b/src/server/events/Connect.hpp @@ -45,12 +45,12 @@ namespace Events { class Connect : public Event { public: - Connect(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& tail, - const Raul::Path& head); + Connect(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& tail, + const Raul::Path& head); bool pre_process(); void execute(ProcessContext& context); diff --git a/src/server/events/CreateNode.cpp b/src/server/events/CreateNode.cpp index 210dc2e3..76f29613 100644 --- a/src/server/events/CreateNode.cpp +++ b/src/server/events/CreateNode.cpp @@ -33,7 +33,7 @@ namespace Server { namespace Events { CreateNode::CreateNode(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& path, diff --git a/src/server/events/CreateNode.hpp b/src/server/events/CreateNode.hpp index 90b2b2b6..358c2eae 100644 --- a/src/server/events/CreateNode.hpp +++ b/src/server/events/CreateNode.hpp @@ -41,7 +41,7 @@ class CreateNode : public Event { public: CreateNode(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& node_path, diff --git a/src/server/events/CreatePatch.cpp b/src/server/events/CreatePatch.cpp index 9d1280e1..b6b62f71 100644 --- a/src/server/events/CreatePatch.cpp +++ b/src/server/events/CreatePatch.cpp @@ -30,7 +30,7 @@ namespace Server { namespace Events { CreatePatch::CreatePatch(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& path, diff --git a/src/server/events/CreatePatch.hpp b/src/server/events/CreatePatch.hpp index f84e2683..be19d54e 100644 --- a/src/server/events/CreatePatch.hpp +++ b/src/server/events/CreatePatch.hpp @@ -36,7 +36,7 @@ class CreatePatch : public Event { public: CreatePatch(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& path, diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 684e2fb0..9ddb8894 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -36,7 +36,7 @@ namespace Server { namespace Events { CreatePort::CreatePort(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& path, diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index 9a524c30..22304b4c 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -42,7 +42,7 @@ class CreatePort : public Event { public: CreatePort(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, const Raul::Path& path, diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index 6c322059..7ef4d2a5 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -34,11 +34,11 @@ namespace Ingen { namespace Server { namespace Events { -Delete::Delete(Engine& engine, - Interface* client, - int32_t id, - FrameTime time, - const Raul::URI& uri) +Delete::Delete(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + FrameTime time, + const Raul::URI& uri) : Event(engine, client, id, time) , _uri(uri) , _store_iterator(engine.engine_store()->end()) diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp index 80051336..45a92cd7 100644 --- a/src/server/events/Delete.hpp +++ b/src/server/events/Delete.hpp @@ -55,11 +55,11 @@ class DisconnectAll; class Delete : public Event { public: - Delete(Engine& engine, - Interface* client, - int32_t id, - FrameTime timestamp, - const Raul::URI& uri); + Delete(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + FrameTime timestamp, + const Raul::URI& uri); ~Delete(); diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index c0750285..8da4b230 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -48,15 +48,15 @@ namespace Events { typedef Resource::Properties Properties; -Delta::Delta(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - bool create, - Resource::Graph context, - const Raul::URI& subject, - const Properties& properties, - const Properties& remove) +Delta::Delta(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + bool create, + Resource::Graph context, + const Raul::URI& subject, + const Properties& properties, + const Properties& remove) : Event(engine, client, id, timestamp) , _create_event(NULL) , _subject(subject) diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp index bedba5ca..d3c6e5db 100644 --- a/src/server/events/Delta.hpp +++ b/src/server/events/Delta.hpp @@ -70,7 +70,7 @@ class Delta : public Event { public: Delta(Engine& engine, - Interface* client, + SharedPtr<Interface> client, int32_t id, SampleCount timestamp, bool create, diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index fc6813ea..3ad9f650 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -40,12 +40,12 @@ namespace Ingen { namespace Server { namespace Events { -Disconnect::Disconnect(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& tail_path, - const Raul::Path& head_path) +Disconnect::Disconnect(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& tail_path, + const Raul::Path& head_path) : Event(engine, client, id, timestamp) , _tail_path(tail_path) , _head_path(head_path) diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp index 68356e84..1f846806 100644 --- a/src/server/events/Disconnect.hpp +++ b/src/server/events/Disconnect.hpp @@ -45,12 +45,12 @@ namespace Events { class Disconnect : public Event { public: - Disconnect(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& tail_path, - const Raul::Path& head_path); + Disconnect(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& tail_path, + const Raul::Path& head_path); bool pre_process(); void execute(ProcessContext& context); diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp index d9f8b8c1..d360073c 100644 --- a/src/server/events/DisconnectAll.cpp +++ b/src/server/events/DisconnectAll.cpp @@ -40,12 +40,12 @@ namespace Ingen { namespace Server { namespace Events { -DisconnectAll::DisconnectAll(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& parent_path, - const Raul::Path& node_path) +DisconnectAll::DisconnectAll(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& parent_path, + const Raul::Path& node_path) : Event(engine, client, id, timestamp) , _parent_path(parent_path) , _path(node_path) diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp index 1446d962..4f7d13f4 100644 --- a/src/server/events/DisconnectAll.hpp +++ b/src/server/events/DisconnectAll.hpp @@ -43,12 +43,12 @@ class Disconnect; class DisconnectAll : public Event { public: - DisconnectAll(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& parent, - const Raul::Path& object); + DisconnectAll(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& parent, + const Raul::Path& object); DisconnectAll(Engine& engine, PatchImpl* parent, diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp index 6e0aafda..24f3d1d9 100644 --- a/src/server/events/Get.cpp +++ b/src/server/events/Get.cpp @@ -35,11 +35,11 @@ namespace Events { static void send_patch(Interface* client, const PatchImpl* patch); -Get::Get(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::URI& uri) +Get::Get(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::URI& uri) : Event(engine, client, id, timestamp) , _uri(uri) , _object(NULL) @@ -130,7 +130,7 @@ Get::post_process() if (_uri == "ingen:plugins") { respond(SUCCESS); if (_request_client) { - _engine.broadcaster()->send_plugins_to(_request_client, _plugins); + _engine.broadcaster()->send_plugins_to(_request_client.get(), _plugins); } } else if (_uri == "ingen:engine") { respond(SUCCESS); @@ -154,11 +154,11 @@ Get::post_process() const PatchImpl* patch = NULL; const PortImpl* port = NULL; if ((patch = dynamic_cast<const PatchImpl*>(_object))) { - send_patch(_request_client, patch); + send_patch(_request_client.get(), patch); } else if ((node = dynamic_cast<const NodeImpl*>(_object))) { - send_node(_request_client, node); + send_node(_request_client.get(), node); } else if ((port = dynamic_cast<const PortImpl*>(_object))) { - send_port(_request_client, port); + send_port(_request_client.get(), port); } _request_client->bundle_end(); } else if (_plugin) { diff --git a/src/server/events/Get.hpp b/src/server/events/Get.hpp index f1b5003d..adc3f0bb 100644 --- a/src/server/events/Get.hpp +++ b/src/server/events/Get.hpp @@ -38,11 +38,11 @@ namespace Events { class Get : public Event { public: - Get(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::URI& uri); + Get(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::URI& uri); bool pre_process(); void execute(ProcessContext& context) {} diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index 84deba05..9a894e43 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -31,12 +31,12 @@ namespace Ingen { namespace Server { namespace Events { -Move::Move(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& path, - const Raul::Path& new_path) +Move::Move(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& path, + const Raul::Path& new_path) : Event(engine, client, id, timestamp) , _old_path(path) , _new_path(new_path) diff --git a/src/server/events/Move.hpp b/src/server/events/Move.hpp index 2e21b190..31bf1f07 100644 --- a/src/server/events/Move.hpp +++ b/src/server/events/Move.hpp @@ -44,12 +44,12 @@ namespace Events { class Move : public Event { public: - Move(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - const Raul::Path& old_path, - const Raul::Path& new_path); + Move(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + const Raul::Path& old_path, + const Raul::Path& new_path); ~Move(); diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp index f01f1966..31152e01 100644 --- a/src/server/events/SetPortValue.cpp +++ b/src/server/events/SetPortValue.cpp @@ -36,12 +36,12 @@ namespace Server { namespace Events { /** Internal */ -SetPortValue::SetPortValue(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - PortImpl* port, - const Raul::Atom& value) +SetPortValue::SetPortValue(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + PortImpl* port, + const Raul::Atom& value) : Event(engine, client, id, timestamp) , _queued(false) , _port_path(port->path()) diff --git a/src/server/events/SetPortValue.hpp b/src/server/events/SetPortValue.hpp index cdda9d99..569023c5 100644 --- a/src/server/events/SetPortValue.hpp +++ b/src/server/events/SetPortValue.hpp @@ -42,12 +42,12 @@ namespace Events { class SetPortValue : public Event { public: - SetPortValue(Engine& engine, - Interface* client, - int32_t id, - SampleCount timestamp, - PortImpl* port, - const Raul::Atom& value); + SetPortValue(Engine& engine, + SharedPtr<Interface> client, + int32_t id, + SampleCount timestamp, + PortImpl* port, + const Raul::Atom& value); ~SetPortValue(); |