summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-16 04:43:26 +0000
committerDavid Robillard <d@drobilla.net>2008-08-16 04:43:26 +0000
commit20e16797b9ee1de90d8409bd15212b9800c9d6da (patch)
tree77dcc6259b429a114919bd8c934ba6de4637f813
parentbf6f4d0a409ba76e65d375ef75533d6a6062a228 (diff)
downloadingen-20e16797b9ee1de90d8409bd15212b9800c9d6da.tar.gz
ingen-20e16797b9ee1de90d8409bd15212b9800c9d6da.tar.bz2
ingen-20e16797b9ee1de90d8409bd15212b9800c9d6da.zip
Fix 'ingen -egl'.
Never crash on an HTTP message (remove asserts, return errors instead). git-svn-id: http://svn.drobilla.net/lad/ingen@1399 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/libs/engine/HTTPEngineReceiver.cpp34
-rw-r--r--src/libs/gui/Makefile.am3
-rw-r--r--src/libs/module/World.hpp4
-rw-r--r--src/progs/ingen/main.cpp3
4 files changed, 31 insertions, 13 deletions
diff --git a/src/libs/engine/HTTPEngineReceiver.cpp b/src/libs/engine/HTTPEngineReceiver.cpp
index 3c1f7333..b9cd1d7b 100644
--- a/src/libs/engine/HTTPEngineReceiver.cpp
+++ b/src/libs/engine/HTTPEngineReceiver.cpp
@@ -25,6 +25,7 @@
#include "module/Module.hpp"
#include "serialisation/serialisation.hpp"
#include "serialisation/Serialiser.hpp"
+#include "serialisation/Loader.hpp"
#include "engine/ThreadManager.hpp"
#include "HTTPEngineReceiver.hpp"
#include "QueuedEventSource.hpp"
@@ -32,6 +33,7 @@
#include "EngineStore.hpp"
using namespace std;
+using namespace Ingen::Shared;
namespace Ingen {
@@ -50,13 +52,17 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port)
if (!engine.world()->serialisation_module)
engine.world()->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
- if (engine.world()->serialisation_module)
+ if (engine.world()->serialisation_module) {
if (!engine.world()->serialiser)
engine.world()->serialiser = SharedPtr<Serialiser>(
Ingen::Serialisation::new_serialiser(engine.world()));
-
- if (!engine.world()->serialiser)
+
+ if (!engine.world()->loader)
+ engine.world()->loader = SharedPtr<Loader>(
+ Ingen::Serialisation::new_loader());
+ } else {
cerr << "WARNING: Failed to load ingen_serialisation module, HTTP disabled." << endl;
+ }
}
@@ -95,13 +101,12 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
{
HTTPEngineReceiver* me = (HTTPEngineReceiver*)data;
- if (msg->method != SOUP_METHOD_GET && msg->method != SOUP_METHOD_PUT) {
- soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
+ SharedPtr<Store> store = me->_engine.world()->store;
+ if (!store) {
+ soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
-
- SharedPtr<Store> store = me->_engine.world()->store;
- assert(store);
+
if (!Path::is_valid(path)) {
soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
return;
@@ -126,8 +131,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
// Serialise object
string base_uri = string("ingen:").append(start->second->path());
- const string response = serialiser->to_string(start->second, base_uri,
- GraphObject::Variables());
+ const string response = serialiser->to_string(start->second, base_uri, GraphObject::Variables());
soup_message_set_status (msg, SOUP_STATUS_OK);
soup_message_set_response (msg, "text/plain", SOUP_MEMORY_COPY,
response.c_str(), response.length());
@@ -142,6 +146,16 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const
return;
}
+ // Get loader
+ SharedPtr<Loader> loader = me->_engine.world()->loader;
+ if (!loader) {
+ soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ return;
+ }
+
+ // Load object
+ soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
+ } else {
soup_message_set_status (msg, SOUP_STATUS_NOT_IMPLEMENTED);
}
}
diff --git a/src/libs/gui/Makefile.am b/src/libs/gui/Makefile.am
index 17672a29..fa956fca 100644
--- a/src/libs/gui/Makefile.am
+++ b/src/libs/gui/Makefile.am
@@ -29,8 +29,9 @@ libingen_gui_la_CXXFLAGS = \
libingen_gui_la_LDFLAGS = -no-undefined -module -avoid-version
libingen_gui_la_LIBADD = \
- ../client/libingen_client.la \
../module/libingen_module.la \
+ ../shared/libingen_shared.la \
+ ../client/libingen_client.la \
@CURL_LIBS@ \
@FLOWCANVAS_LIBS@ \
@GNOMECANVASMM_LIBS@ \
diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp
index eed98085..a1a0d5c7 100644
--- a/src/libs/module/World.hpp
+++ b/src/libs/module/World.hpp
@@ -34,8 +34,9 @@ namespace Redland { class World; }
namespace Ingen {
class Engine;
-namespace Serialisation { class Serialiser; }
+namespace Serialisation { class Serialiser; class Loader; }
using Serialisation::Serialiser;
+using Serialisation::Loader;
namespace Shared {
class EngineInterface;
@@ -63,6 +64,7 @@ struct World {
SharedPtr<EngineInterface> engine;
SharedPtr<Engine> local_engine;
SharedPtr<Serialiser> serialiser;
+ SharedPtr<Loader> loader;
SharedPtr<Store> store;
SharedPtr<Glib::Module> serialisation_module;
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
index 47f7a038..b4e930a4 100644
--- a/src/progs/ingen/main.cpp
+++ b/src/progs/ingen/main.cpp
@@ -160,7 +160,8 @@ main(int argc, char** argv)
parent_path = args.path_arg;
bool found = false;
- world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
+ if (!world->serialisation_module)
+ world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
Serialisation::Loader* (*new_loader)() = NULL;