diff --git a/calexium_lib/web/CXM_multihost_http_server.anubis b/calexium_lib/web/CXM_multihost_http_server.anubis index 0d8e552..0750205 100644 --- a/calexium_lib/web/CXM_multihost_http_server.anubis +++ b/calexium_lib/web/CXM_multihost_http_server.anubis @@ -733,12 +733,33 @@ define String = "[" + virtual_machine_id + "] ". + +define One + put + ( + ByteArray source, + ByteArray dest, + Int32 position, + Int32 i + ) = + if nth(i,source) is + { + failure then unique, + success(b) then if put(dest,position,b) is + { + failure then unique, + success(_) then put(source,dest,position+1,i+1) + } + }. + define ReadResult read_from_connexion ( BufferedConnection connection, Int32 size, - Int32 time_out + Int32 time_out, + ByteArray result_buffer, + Int32 position ) = //println(pid + "read_from_connexion(" + size + ")"); @@ -747,18 +768,20 @@ define ReadResult //with t1_tmp = (UTime) now, with result = extract(*connection.buffer, *connection.read_pos, *connection.read_pos + size), size_read = length(result), + put(result,result_buffer,position,0); connection.read_pos <- *connection.read_pos + size_read; //accumulate_t1(t1_tmp); - if size > size_read - then + if size > size_read then //println("Wanted " + size + ", read only " + size_read); - if read_from_connexion(connection, size - size_read, time_out) is - { - error then error, - timeout then ok(result), - ok(ba) then ok(result + ba) - } - else ok(result) + + terminal read_from_connexion(connection, size - size_read, time_out, result_buffer,position+size_read) +// { +// error then error, +// timeout then ok(result), +// ok(ba) then ok(result + ba) +// } + else + ok(result_buffer) else //if now > dead_line then record_dubious_connection(connection,dead_line,dos) else if read(connection.conn, 16384, time_out) is // the connection is closed after 10 minutes of inactivity @@ -770,7 +793,8 @@ define ReadResult connection.buffer <- ba; connection.read_pos <- 0; //println(pid + "rb = " + length(*read_buffer)); - read_from_connexion(connection, size, time_out) + + terminal read_from_connexion(connection, size, time_out, result_buffer,position) }. define Result(Error,Word8) @@ -791,7 +815,7 @@ define Result(Error,Word8) if nth(*connection.read_pos, *connection.buffer) is { failure then - if read_from_connexion(connection,1,600) is // the connection is closed after 10 minutes of inactivity + if read_from_connexion(connection,1,600, constant_byte_array(1,0),0) is // the connection is closed after 10 minutes of inactivity { error then /*accumulate_t2(t2_tmp);*/ error(cannot_read_from_connection), timeout then /*accumulate_t2(t2_tmp);*/ error(timeout(600)), @@ -1719,7 +1743,7 @@ define Result(Error,ByteArray) ) = if body_size = 0 then ok(constant_byte_array(0,0)) else if retries =< 0 then error(cannot_read_from_connection) else - if read_from_connexion(connection,body_size,60) is + if read_from_connexion(connection,body_size,60,constant_byte_array(body_size,0),0) is { error then error(cannot_read_from_connection), timeout then error(timeout(60)), -- libgit2 0.21.4