summaryrefslogtreecommitdiff
path: root/share/server
diff options
context:
space:
mode:
Diffstat (limited to 'share/server')
-rw-r--r--share/server/loop.js6
-rw-r--r--share/server/state.js4
-rw-r--r--share/server/views.js12
3 files changed, 18 insertions, 4 deletions
diff --git a/share/server/loop.js b/share/server/loop.js
index 170a8dc8..db6a9702 100644
--- a/share/server/loop.js
+++ b/share/server/loop.js
@@ -28,7 +28,7 @@ try {
//
// Responses are json values followed by a new line ("\n")
-var cmd, cmdkey;
+var line, cmd, cmdkey;
var dispatch = {
"reset" : State.reset,
@@ -43,7 +43,9 @@ var dispatch = {
"list_tail" : Render.listTail
};
-while (cmd = eval(readline())) {
+while (line = eval(readline())) {
+ cmd = eval(line)
+ line_length = line.length
try {
cmdkey = cmd.shift();
if (dispatch[cmdkey]) {
diff --git a/share/server/state.js b/share/server/state.js
index 05c55a1b..6c7d63b9 100644
--- a/share/server/state.js
+++ b/share/server/state.js
@@ -13,12 +13,14 @@
// globals used by other modules and functions
var funs = []; // holds functions used for computation
var funsrc = []; // holds function source for debug info
+var query_config = {};
var State = (function() {
return {
- reset : function() {
+ reset : function(config) {
// clear the globals and run gc
funs = [];
funsrc = [];
+ query_config = config;
gc();
print("true"); // indicates success
},
diff --git a/share/server/views.js b/share/server/views.js
index c6d71579..de728ac2 100644
--- a/share/server/views.js
+++ b/share/server/views.js
@@ -46,7 +46,17 @@ var Views = (function() {
reductions[i] = null;
}
}
- print("[true," + toJSON(reductions) + "]");
+ var reduce_line = toJSON(reductions);
+ var reduce_length = reduce_line.length;
+ if (query_config && query_config.reduce_limit &&
+ reduce_length > 200 && ((reduce_length * 2) > line.length)) {
+ throw {
+ error:"reduce_overflow_error",
+ reason: "Reduce output must shrink more rapidly. Current output: '"+reduce_line+"'"
+ };
+ } else {
+ print("[true," + reduce_line + "]");
+ }
};
return {