diff options
Diffstat (limited to 'src')
28 files changed, 255 insertions, 33 deletions
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index cf9e06a0..4c4e452c 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -429,6 +429,31 @@ ClientStore::new_plugin(const string& uri, const string& type_uri, const string& void +ClientStore::new_object(const Shared::GraphObject* object) +{ + using namespace Shared; + + const Patch* patch = dynamic_cast<const Patch*>(object); + if (patch) { + new_patch(patch->path(), patch->internal_polyphony()); + return; + } + + const Node* node = dynamic_cast<const Node*>(object); + if (node) { + new_node(node->path(), node->plugin()->uri()); + return; + } + + const Port* port = dynamic_cast<const Port*>(object); + if (port) { + new_port(port->path(), port->type().uri(), port->index(), !port->is_input()); + return; + } +} + + +void ClientStore::new_patch(const string& path, uint32_t poly) { SharedPtr<PatchModel> p(new PatchModel(path, poly)); diff --git a/src/client/ClientStore.hpp b/src/client/ClientStore.hpp index 944ab752..2387f519 100644 --- a/src/client/ClientStore.hpp +++ b/src/client/ClientStore.hpp @@ -70,6 +70,7 @@ public: // CommonInterface void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name); + void new_object(const Shared::GraphObject* object); void new_patch(const string& path, uint32_t poly); void new_node(const string& path, const string& plugin_uri); void new_port(const string& path, const string& type, uint32_t index, bool is_output); diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp index 572ff548..b314a7b7 100644 --- a/src/client/HTTPClientReceiver.cpp +++ b/src/client/HTTPClientReceiver.cpp @@ -56,9 +56,9 @@ HTTPClientReceiver::Listener::~Listener() close(_sock); } -HTTPClientReceiver::Listener::Listener(SoupSession* session, const std::string uri) +HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::string uri) : _uri(uri) - , _session(session) + , _receiver(receiver) { string port_str = uri.substr(uri.find_last_of(":")+1); int port = atoi(port_str.c_str()); @@ -94,25 +94,34 @@ HTTPClientReceiver::Listener::Listener(SoupSession* session, const std::string u } } +void +HTTPClientReceiver::update(const std::string& str) +{ + cout << "UPDATE: " << str << endl; + cout << _parser->parse_string(_world, _target.get(), str, "/", "/"); +} void HTTPClientReceiver::Listener::_run() { - char in = '\0'; - char last = '\0'; - string recv = ""; + char in = '\0'; + char last = '\0'; + char llast = '\0'; + string recv = ""; while (true) { while (read(_sock, &in, 1) > 0 ) { recv += in; - if (last == '\n' && in == '\n') { + if (in == '\n' && last == '\n' && llast == '\n') { if (recv != "") { - cout << "RECEIVED UPDATE:\n" << recv << endl; + _receiver->update(recv); recv = ""; last = '\0'; + llast = '\0'; } break; } + llast = last; last = in; } } @@ -129,11 +138,13 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi if (path == "/") { me->_target->response_ok(0); me->_target->enable(); + } else if (path == "/plugins") { if (msg->response_body->data == NULL) { cout << "ERROR: Empty response" << endl; } else { + Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); me->_target->enable(); me->_parser->parse_string(me->_world, me->_target.get(), @@ -145,6 +156,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi if (msg->response_body->data == NULL) { cout << "ERROR: Empty response" << endl; } else { + Glib::Mutex::Lock lock(me->_mutex); me->_target->response_ok(0); me->_target->enable(); me->_parser->parse_string(me->_world, me->_target.get(), @@ -156,11 +168,12 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi if (msg->response_body->data == NULL) { cout << "ERROR: Empty response" << endl; } else { + Glib::Mutex::Lock lock(me->_mutex); string uri = string(soup_uri_to_string(soup_message_get_uri(msg), false)); uri = uri.substr(0, uri.find_last_of(":")); uri += string(":") + msg->response_body->data; cout << "Stream URI: " << uri << endl; - me->_listener = boost::shared_ptr<Listener>(new Listener(me->_session, uri)); + me->_listener = boost::shared_ptr<Listener>(new Listener(me, uri)); me->_listener->start(); } diff --git a/src/client/HTTPClientReceiver.hpp b/src/client/HTTPClientReceiver.hpp index 015a551f..60b458ac 100644 --- a/src/client/HTTPClientReceiver.hpp +++ b/src/client/HTTPClientReceiver.hpp @@ -21,6 +21,7 @@ #include <cstdlib> #include <boost/utility.hpp> #include <libsoup/soup.h> +#include <glibmm/thread.h> #include "redlandmm/World.hpp" #include "raul/Deletable.hpp" #include "raul/Thread.hpp" @@ -48,20 +49,23 @@ public: private: static void message_callback(SoupSession* session, SoupMessage* msg, void* ptr); + void update(const std::string& str); + class Listener : public Raul::Thread { public: - Listener(SoupSession* session, const std::string uri); + Listener(HTTPClientReceiver* receiver, const std::string uri); ~Listener(); void _run(); private: - std::string _uri; - int _sock; - SoupSession* _session; + std::string _uri; + int _sock; + HTTPClientReceiver* _receiver; }; friend class Listener; SharedPtr<Listener> _listener; + Glib::Mutex _mutex; SharedPtr<Shared::ClientInterface> _target; Shared::World* _world; diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp index 1eb9ad6e..7392f9d2 100644 --- a/src/client/OSCEngineSender.cpp +++ b/src/client/OSCEngineSender.cpp @@ -18,6 +18,9 @@ #include <iostream> #include "raul/AtomLiblo.hpp" #include "OSCEngineSender.hpp" +#include "common/interface/Patch.hpp" +#include "common/interface/Port.hpp" +#include "common/interface/Plugin.hpp" using namespace std; using Raul::Atom; @@ -127,6 +130,32 @@ OSCEngineSender::quit() // Object commands + +void +OSCEngineSender::new_object(const Shared::GraphObject* object) +{ + using namespace Shared; + + const Patch* patch = dynamic_cast<const Patch*>(object); + if (patch) { + new_patch(patch->path(), patch->internal_polyphony()); + return; + } + + const Node* node = dynamic_cast<const Node*>(object); + if (node) { + new_node(node->path(), node->plugin()->uri()); + return; + } + + const Port* port = dynamic_cast<const Port*>(object); + if (port) { + new_port(port->path(), port->type().uri(), port->index(), !port->is_input()); + return; + } +} + + void OSCEngineSender::new_patch(const string& path, uint32_t poly) diff --git a/src/client/OSCEngineSender.hpp b/src/client/OSCEngineSender.hpp index 12b062e4..ba851d68 100644 --- a/src/client/OSCEngineSender.hpp +++ b/src/client/OSCEngineSender.hpp @@ -80,6 +80,8 @@ public: // Object commands + void new_object(const Shared::GraphObject* object); + void new_patch(const string& path, uint32_t poly); diff --git a/src/client/SigClientInterface.hpp b/src/client/SigClientInterface.hpp index 36ca44b9..046dbcbb 100644 --- a/src/client/SigClientInterface.hpp +++ b/src/client/SigClientInterface.hpp @@ -47,6 +47,7 @@ public: std::string uri() const { return "(internal)"; } // Signal parameters match up directly with ClientInterface calls + sigc::signal<void, const Shared::GraphObject*> signal_new_object; sigc::signal<void, int32_t> signal_response_ok; sigc::signal<void, int32_t, string> signal_response_error; @@ -103,6 +104,9 @@ protected: void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name) { if (_enabled) signal_new_plugin.emit(uri, type_uri, symbol, name); } + void new_object(const Shared::GraphObject* object) + { if (_enabled) signal_new_object.emit(object); } + void new_patch(const string& path, uint32_t poly) { if (_enabled) signal_new_patch.emit(path, poly); } diff --git a/src/client/ThreadedSigClientInterface.cpp b/src/client/ThreadedSigClientInterface.cpp index ef95133b..b430a0a0 100644 --- a/src/client/ThreadedSigClientInterface.cpp +++ b/src/client/ThreadedSigClientInterface.cpp @@ -15,8 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "ThreadedSigClientInterface.hpp" #include <iostream> +#include "common/interface/Patch.hpp" +#include "common/interface/Plugin.hpp" +#include "common/interface/Port.hpp" +#include "ThreadedSigClientInterface.hpp" using namespace std; @@ -74,5 +77,29 @@ ThreadedSigClientInterface::emit_signals() } +void +ThreadedSigClientInterface::new_object(const Shared::GraphObject* object) +{ + using namespace Shared; + const Patch* patch = dynamic_cast<const Patch*>(object); + if (patch) { + new_patch(patch->path(), patch->internal_polyphony()); + return; + } + + const Node* node = dynamic_cast<const Node*>(object); + if (node) { + new_node(node->path(), node->plugin()->uri()); + return; + } + + const Port* port = dynamic_cast<const Port*>(object); + if (port) { + new_port(port->path(), port->type().uri(), port->index(), !port->is_input()); + return; + } +} + + } // namespace Client } // namespace Ingen diff --git a/src/client/ThreadedSigClientInterface.hpp b/src/client/ThreadedSigClientInterface.hpp index 968954bc..984f9cad 100644 --- a/src/client/ThreadedSigClientInterface.hpp +++ b/src/client/ThreadedSigClientInterface.hpp @@ -97,6 +97,8 @@ public: void new_plugin(const string& uri, const string& type_uri, const string& symbol, const string& name) { push_sig(sigc::bind(new_plugin_slot, uri, type_uri, symbol, name)); } + void new_object(const Shared::GraphObject* object); + void new_patch(const string& path, uint32_t poly) { push_sig(sigc::bind(new_patch_slot, path, poly)); } diff --git a/src/common/interface/CommonInterface.hpp b/src/common/interface/CommonInterface.hpp index d5a40711..d0d81945 100644 --- a/src/common/interface/CommonInterface.hpp +++ b/src/common/interface/CommonInterface.hpp @@ -23,6 +23,7 @@ #include "raul/SharedPtr.hpp" #include "raul/Atom.hpp" #include "interface/CommonInterface.hpp" +#include "interface/GraphObject.hpp" namespace Ingen { namespace Shared { @@ -44,6 +45,8 @@ public: /** End (and send) an atomic bundle */ virtual void bundle_end() = 0; + virtual void new_object(const GraphObject* object) = 0; + virtual void new_patch(const std::string& path, uint32_t poly) = 0; diff --git a/src/common/interface/GraphObject.hpp b/src/common/interface/GraphObject.hpp index a82dd278..cf623c3c 100644 --- a/src/common/interface/GraphObject.hpp +++ b/src/common/interface/GraphObject.hpp @@ -48,6 +48,8 @@ public: typedef PathTable< SharedPtr<GraphObject> >::const_iterator const_iterator; + virtual void set_path(const Raul::Path& path) = 0; + virtual const Raul::Path path() const = 0; virtual const Raul::Symbol symbol() const = 0; virtual const Variables& variables() const = 0; diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index 19cb0cd4..aaee7b4a 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -245,9 +245,21 @@ ClientBroadcaster::send_program_remove(const string& node_path, int bank, int pr } +/** Send an object. + * + * @param recursive If true send all children of object + */ +void +ClientBroadcaster::send_object(const GraphObjectImpl* p, bool recursive) +{ + for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) + ObjectSender::send_object((*i).second, p, recursive); +} + + /** Send a patch. * - * Sends all objects underneath Patch - contained Nodes, etc. + * @param recursive If true send all children of object */ void ClientBroadcaster::send_patch(const PatchImpl* p, bool recursive) diff --git a/src/engine/ClientBroadcaster.hpp b/src/engine/ClientBroadcaster.hpp index 2de4b1b9..9ddf1ed7 100644 --- a/src/engine/ClientBroadcaster.hpp +++ b/src/engine/ClientBroadcaster.hpp @@ -31,6 +31,7 @@ using std::string; namespace Ingen { +class GraphObjectImpl; class NodeImpl; class PortImpl; class PluginImpl; @@ -61,11 +62,12 @@ public: void bundle_begin(); void bundle_end(); - + // Error that isn't the direct result of a request void send_error(const string& msg); - + void send_plugins(const NodeFactory::Plugins& plugin_list); + void send_object(const GraphObjectImpl* p, bool recursive); void send_patch(const PatchImpl* p, bool recursive); void send_node(const NodeImpl* node, bool recursive); void send_port(const PortImpl* port); diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index ec60cb44..413dfe7f 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -17,7 +17,10 @@ #include <string> #include "raul/Atom.hpp" +#include "serialisation/Serialiser.hpp" +#include "module/World.hpp" #include "HTTPClientSender.hpp" +#include "Engine.hpp" using namespace std; using namespace Raul; @@ -74,6 +77,7 @@ HTTPClientSender::destroy(const std::string& path) void HTTPClientSender::patch_cleared(const std::string& patch_path) { + send_chunk(string("<").append(patch_path).append("> ingen:empty true .")); //send("/ingen/patch_cleared", "s", patch_path.c_str(), LO_ARGS_END); } @@ -140,6 +144,20 @@ HTTPClientSender::activity(const std::string& path) //lo_send(_address, "/ingen/activity", "s", port_path.c_str(), LO_ARGS_END); } +static void null_deleter(const Shared::GraphObject*) {} + +void +HTTPClientSender::new_object(const Shared::GraphObject* object) +{ + SharedPtr<Serialisation::Serialiser> serialiser = _engine.world()->serialiser; + serialiser->start_to_string("/", ""); + // FIXME + boost::shared_ptr<Shared::GraphObject> obj((Shared::GraphObject*)object, null_deleter); + serialiser->serialise(obj); + string str = serialiser->finish(); + send_chunk(str); +} + void HTTPClientSender::new_plugin(const std::string& uri, @@ -159,7 +177,7 @@ HTTPClientSender::new_plugin(const std::string& uri, void HTTPClientSender::new_patch(const std::string& path, uint32_t poly) { - send_chunk(string("<").append(path).append("> a ingen:Patch")); + //send_chunk(string("<").append(path).append("> a ingen:Patch")); } diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index 57aaed0e..5dc658d7 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -30,6 +30,8 @@ namespace Ingen { +class Engine; + namespace Shared { class EngineInterface; } @@ -44,7 +46,8 @@ class HTTPClientSender , public Shared::HTTPSender { public: - HTTPClientSender() + HTTPClientSender(Engine& engine) + : _engine(engine) {} bool enabled() const { return _enabled; } @@ -69,6 +72,8 @@ public: void response_error(int32_t id, const std::string& msg); void error(const std::string& msg); + + virtual void new_object(const Shared::GraphObject* object); virtual void new_plugin(const std::string& uri, const std::string& type_uri, @@ -125,6 +130,7 @@ public: uint32_t program); private: + Engine& _engine; std::string _url; bool _enabled; }; diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp index 82bebc0c..bda30264 100644 --- a/src/engine/HTTPEngineReceiver.cpp +++ b/src/engine/HTTPEngineReceiver.cpp @@ -150,7 +150,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const path = '/' + path.substr(6); } else if (path.substr(0, 7) == "/stream") { - HTTPClientSender* client = new HTTPClientSender(); + HTTPClientSender* client = new HTTPClientSender(me->_engine); me->register_client(client); // Respond with port number of stream for client diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index aa99c1d8..fb87ba23 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -313,6 +313,31 @@ OSCClientSender::new_plugin(const std::string& uri, } +void +OSCClientSender::new_object(const Shared::GraphObject* object) +{ + using namespace Shared; + + const Patch* patch = dynamic_cast<const Patch*>(object); + if (patch) { + new_patch(patch->path(), patch->internal_polyphony()); + return; + } + + const Node* node = dynamic_cast<const Node*>(object); + if (node) { + new_node(node->path(), node->plugin()->uri()); + return; + } + + const Port* port = dynamic_cast<const Port*>(object); + if (port) { + new_port(port->path(), port->type().uri(), port->index(), !port->is_input()); + return; + } +} + + /** \page client_osc_namespace * <p> \b /ingen/new_patch - Notification of a new patch * \arg \b path (string) - Path of new patch diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index 879484c8..04f240fe 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -25,6 +25,7 @@ #include <pthread.h> #include "types.hpp" #include "interface/ClientInterface.hpp" +#include "interface/GraphObject.hpp" #include "shared/OSCSender.hpp" namespace Ingen { @@ -76,6 +77,8 @@ public: const std::string& symbol, const std::string& name); + virtual void new_object(const Shared::GraphObject* object); + virtual void new_patch(const std::string& path, uint32_t poly); virtual void new_node(const std::string& path, diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp index bb2de6f8..8f38b738 100644 --- a/src/engine/ObjectSender.cpp +++ b/src/engine/ObjectSender.cpp @@ -31,6 +31,31 @@ namespace Ingen { void +ObjectSender::send_object(ClientInterface* client, const GraphObjectImpl* object, bool recursive) +{ + client->new_object(object); + + const PatchImpl* patch = dynamic_cast<const PatchImpl*>(object); + if (patch) { + send_patch(client, patch, recursive); + return; + } + + const NodeImpl* node = dynamic_cast<const NodeImpl*>(object); + if (node) { + send_node(client, node, recursive); + return; + } + + const PortImpl* port = dynamic_cast<const PortImpl*>(object); + if (port) { + send_port(client, port); + return; + } +} + + +void ObjectSender::send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive) { client->bundle_begin(); diff --git a/src/engine/ObjectSender.hpp b/src/engine/ObjectSender.hpp index 9b6eb000..e546fe2f 100644 --- a/src/engine/ObjectSender.hpp +++ b/src/engine/ObjectSender.hpp @@ -26,6 +26,7 @@ namespace Shared { class ClientInterface; } using Shared::ClientInterface; +class GraphObjectImpl; class PatchImpl; class NodeImpl; class PortImpl; @@ -43,9 +44,7 @@ class PluginImpl; */ class ObjectSender { public: - - // FIXME: Make all object parameters const - + static void send_object(ClientInterface* client, const GraphObjectImpl* object, bool recursive); static void send_patch(ClientInterface* client, const PatchImpl* patch, bool recursive); static void send_node(ClientInterface* client, const NodeImpl* node, bool recursive); static void send_port(ClientInterface* client, const PortImpl* port); diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 76866198..62828102 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -139,6 +139,13 @@ QueuedEngineInterface::bundle_end() // Object commands void +QueuedEngineInterface::new_object(const GraphObject* object) +{ + cout << "NEW OBJECT" << endl; +} + + +void QueuedEngineInterface::new_patch(const string& path, uint32_t poly) { diff --git a/src/engine/QueuedEngineInterface.hpp b/src/engine/QueuedEngineInterface.hpp index 82513cb2..e7268e9e 100644 --- a/src/engine/QueuedEngineInterface.hpp +++ b/src/engine/QueuedEngineInterface.hpp @@ -73,6 +73,8 @@ public: // Object commands + virtual void new_object(const Shared::GraphObject* object); + virtual void new_patch(const string& path, uint32_t poly); diff --git a/src/engine/events/CreateNodeEvent.cpp b/src/engine/events/CreateNodeEvent.cpp index d616ce1f..29f7f96e 100644 --- a/src/engine/events/CreateNodeEvent.cpp +++ b/src/engine/events/CreateNodeEvent.cpp @@ -142,7 +142,7 @@ CreateNodeEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _engine.broadcaster()->send_node(_node, true); // yes, send ports + _engine.broadcaster()->send_object(_node, true); // yes, send ports } } diff --git a/src/engine/events/CreatePatchEvent.cpp b/src/engine/events/CreatePatchEvent.cpp index b390770a..56796557 100644 --- a/src/engine/events/CreatePatchEvent.cpp +++ b/src/engine/events/CreatePatchEvent.cpp @@ -127,7 +127,8 @@ CreatePatchEvent::post_process() // Don't send ports/nodes that have been added since prepare() // (otherwise they would be sent twice) - _engine.broadcaster()->send_patch(_patch, false); + //_engine.broadcaster()->send_patch(_patch, false); + _engine.broadcaster()->send_object(_patch, false); } else if (_error == INVALID_PATH) { string msg = "Attempt to create patch with illegal path "; diff --git a/src/engine/events/CreatePortEvent.cpp b/src/engine/events/CreatePortEvent.cpp index b02bec2a..8cb30a4b 100644 --- a/src/engine/events/CreatePortEvent.cpp +++ b/src/engine/events/CreatePortEvent.cpp @@ -154,7 +154,7 @@ CreatePortEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _engine.broadcaster()->send_port(_patch_port); + _engine.broadcaster()->send_object(_patch_port, true); } } diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp index ca322b74..aa7dd774 100644 --- a/src/shared/ClashAvoider.cpp +++ b/src/shared/ClashAvoider.cpp @@ -127,6 +127,15 @@ ClashAvoider::exists(const Raul::Path& path) const void +ClashAvoider::new_object(const GraphObject* object) +{ + // FIXME: + ((GraphObject*)object)->set_path(map_path(object->path())); + _target.new_object(object); +} + + +void ClashAvoider::new_patch(const std::string& path, uint32_t poly) { diff --git a/src/shared/ClashAvoider.hpp b/src/shared/ClashAvoider.hpp index ac2d62bb..ead6d96c 100644 --- a/src/shared/ClashAvoider.hpp +++ b/src/shared/ClashAvoider.hpp @@ -49,6 +49,8 @@ public: // Object commands + void new_object(const GraphObject* object); + void new_patch(const std::string& path, uint32_t poly); diff --git a/src/shared/HTTPSender.cpp b/src/shared/HTTPSender.cpp index 7f760786..1b38f97f 100644 --- a/src/shared/HTTPSender.cpp +++ b/src/shared/HTTPSender.cpp @@ -109,8 +109,9 @@ HTTPSender::_run() _signal.wait(_mutex); write(_client_sock, _transfer.c_str(), _transfer.length()); - write(_client_sock, "\n\n", 2); + write(_client_sock, "\n\n\n", 2); + _signal.broadcast(); _mutex.unlock(); } @@ -125,16 +126,15 @@ HTTPSender::bundle_begin() _mutex.lock(); _send_state = SendingBundle; _transfer = ""; - _mutex.unlock(); } void HTTPSender::bundle_end() { - _mutex.lock(); assert(_send_state == SendingBundle); _signal.broadcast(); + _signal.wait(_mutex); _send_state = Immediate; _mutex.unlock(); } @@ -143,16 +143,15 @@ HTTPSender::bundle_end() void HTTPSender::send_chunk(const std::string& buf) { - _mutex.lock(); - if (_send_state == Immediate) { - _transfer = ""; + _mutex.lock(); + _transfer = buf; _signal.broadcast(); + _signal.wait(_mutex); + _mutex.unlock(); } else { _transfer.append(buf); } - - _mutex.unlock(); } |