summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-08-14 03:08:21 +0000
committerDavid Robillard <d@drobilla.net>2008-08-14 03:08:21 +0000
commit239583b0ef7e37dca95a3bf9f3c16648e6aa140d (patch)
tree25716cec31483ffbe9e0acf36086095a07567339
parent665da1cd4b65de0459fcda0e6e75552a4751c5b6 (diff)
downloadingen-239583b0ef7e37dca95a3bf9f3c16648e6aa140d.tar.gz
ingen-239583b0ef7e37dca95a3bf9f3c16648e6aa140d.tar.bz2
ingen-239583b0ef7e37dca95a3bf9f3c16648e6aa140d.zip
Gracefully handle illegal port paths from client for set_port_value.
git-svn-id: http://svn.drobilla.net/lad/ingen@1364 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp27
-rw-r--r--src/libs/engine/events/SetPortValueEvent.hpp2
2 files changed, 21 insertions, 8 deletions
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index a184bd95..4152bb7b 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -91,10 +91,14 @@ void
SetPortValueEvent::pre_process()
{
if (_queued) {
- if (_port == NULL)
- _port = _engine.object_store()->find_port(_port_path);
+ if (_port == NULL) {
+ if (Path::is_valid(_port_path))
+ _port = _engine.object_store()->find_port(_port_path);
+ else
+ _error = ILLEGAL_PATH;
+ }
- if (_port == NULL)
+ if (_port == NULL && _error == NO_ERROR)
_error = PORT_NOT_FOUND;
}
@@ -108,11 +112,16 @@ SetPortValueEvent::execute(ProcessContext& context)
Event::execute(context);
assert(_time >= context.start() && _time <= context.end());
- if (_port == NULL)
- _port = _engine.object_store()->find_port(_port_path);
+ if (_error == NO_ERROR && _port == NULL) {
+ if (Path::is_valid(_port_path))
+ _port = _engine.object_store()->find_port(_port_path);
+ else
+ _error = ILLEGAL_PATH;
+ }
if (_port == NULL) {
- _error = PORT_NOT_FOUND;
+ if (_error == NO_ERROR)
+ _error = PORT_NOT_FOUND;
/*} else if (_port->buffer(0)->capacity() < _data_size) {
_error = NO_SPACE;*/
} else {
@@ -155,9 +164,13 @@ SetPortValueEvent::post_process()
{
if (_error == NO_ERROR) {
assert(_port != NULL);
-
_responder->respond_ok();
_engine.broadcaster()->send_control_change(_port_path, *(float*)_data);
+
+ } else if (_error == ILLEGAL_PATH) {
+ string msg = "Illegal port path \"";
+ msg.append(_port_path).append("\"");
+ _responder->respond_error(msg);
} else if (_error == PORT_NOT_FOUND) {
string msg = "Unable to find port ";
diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp
index 6f89fc20..5c952a61 100644
--- a/src/libs/engine/events/SetPortValueEvent.hpp
+++ b/src/libs/engine/events/SetPortValueEvent.hpp
@@ -66,7 +66,7 @@ public:
void post_process();
private:
- enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE };
+ enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH };
bool _queued;
bool _omni;