diff --git a/web/multihost_http_server.anubis b/web/multihost_http_server.anubis index 27dfb14..6d67599 100644 --- a/web/multihost_http_server.anubis +++ b/web/multihost_http_server.anubis @@ -870,6 +870,34 @@ define One } }. +define Maybe(Int) + fill_buffer + ( + HTTP_Buffered_Connection connection, + Int time_out + )= + if read(connection.conn, 32768, time_out) is // the connection is closed after 10 minutes of inactivity + { + failure then + println("fill_buffer read failure");failure, + success(ba) then + with size_read = length(ba), + //println("size read "+size_read); + //the needed read is higher than the + if size_read = 0 then //time_out + success(0) +// read_from_connexion(connection, size, time_out, result_buffer) +// else if size > size_read then +// put(ba, result_buffer, position, 0); +// read_from_connexion(connection, size - size_read, time_out, result_buffer, position+size_read) + else + //println(pid + "ba = " + length(ba)); + connection.buffer <- ba; + connection.read_pos <- 0; + success(size_read) + } +. + define Maybe(ByteArray) read_from_connexion ( @@ -907,30 +935,35 @@ define Maybe(ByteArray) // println(pid + "content: ["+to_string(current_result_buffer)+"]"); success(current_result_buffer) else + if fill_buffer(connection, time_out) is + { + failure then failure + success(n) then read_from_connexion(connection, size_to_read, time_out, result_buffer) + } //with t0 = (UTime) unow, //if unow > dead_line then record_dubious_connection(connection,dead_line,dos) else - println(pid +"try to read fill buffer with 32768 bytes time out ["+time_out+"]"); - if read(connection.conn, 32768, time_out) is // read with timeout - { - failure then println(pid + "read failed ["+to_string(result_buffer)+"] connection maybe lost"); failure, - success(ba) then - with size_read = length(ba), - println( pid + "read ["+size_read+"] bytes"); - //the needed read is higher than the - if size_read = 0 then - read_from_connexion(connection, size_to_read, time_out, result_buffer) - else if size_to_read > size_read then - //put(ba, result_buffer, position, 0); - with current_result_buffer = result_buffer + ba, - read_from_connexion(connection, size_to_read - size_read, time_out, current_result_buffer) - else - //println(pid + "ba = " + length(ba) + " duration: " + __utime_to_string((UTime) unow - t0)); - connection.buffer <- ba; - connection.read_pos <- 0; - //println(pid + "rb = " + length(*read_buffer)); - - terminal read_from_connexion(connection, size_to_read, time_out, result_buffer) - } +// println(pid +"try to read fill buffer with 32768 bytes time out ["+time_out+"]"); +// if read(connection.conn, 32768, time_out) is // read with timeout +// { +// failure then println(pid + "read failed ["+to_string(result_buffer)+"] connection maybe lost"); failure, +// success(ba) then +// with size_read = length(ba), +// println( pid + "read ["+size_read+"] bytes"); +// //the needed read is higher than the +// if size_read = 0 then +// read_from_connexion(connection, size_to_read, time_out, result_buffer) +// else if size_to_read > size_read then +// //put(ba, result_buffer, position, 0); +// with current_result_buffer = result_buffer + ba, +// read_from_connexion(connection, size_to_read - size_read, time_out, current_result_buffer) +// else +// //println(pid + "ba = " + length(ba) + " duration: " + __utime_to_string((UTime) unow - t0)); +// connection.buffer <- ba; +// connection.read_pos <- 0; +// //println(pid + "rb = " + length(*read_buffer)); +// +// terminal read_from_connexion(connection, size_to_read, time_out, result_buffer) +// } . define Maybe(ByteArray) -- libgit2 0.21.4