Commit ac9a53811e428940fcfad8bedb770e2503166264

Authored by Cédric RICARD
1 parent c3a2fba8

Adding profiling code and logs...

Changing etag from sha1 to MD5
Showing 1 changed file with 28 additions and 4 deletions   Show diff stats
calexium_lib/web/CXM_multihost_http_server.anubis
@@ -490,8 +490,25 @@ public define One @@ -490,8 +490,25 @@ public define One
490 --- That's all for the public part ! -------------------------------------------------- 490 --- That's all for the public part ! --------------------------------------------------
491 491
492 492
  493 +define String
  494 + utime_to_string
  495 + (
  496 + UTime t
  497 + ) =
  498 + integer_to_string(t.seconds) + "." + zero_pad_n(6, t.microseconds ) + "s".
  499 +
493 500
494 - 501 +variable UTime t0 = utime(0,0).
  502 +//variable Int32 t0_s = 0.
  503 +//variable Int32 t0_us = 0.
  504 +
  505 +define One
  506 + print_delta
  507 + (
  508 + String txt
  509 + ) =
  510 +// with t0 = utime(t0_s, t0_us)
  511 + println(utime_to_string((UTime)now - *t0) + " : " + txt).
495 512
496 513
497 514
@@ -2045,7 +2062,7 @@ define String @@ -2045,7 +2062,7 @@ define String
2045 if mb_ftimes is 2062 if mb_ftimes is
2046 { 2063 {
2047 failure then println("Warning: no file times for '" + filename + "', etag won't be very accurate."); to_ascii(sha1((filename, size))), 2064 failure then println("Warning: no file times for '" + filename + "', etag won't be very accurate."); to_ascii(sha1((filename, size))),
2048 - success(ftimes) then to_ascii(sha1((filename, ftimes, size))) 2065 + success(ftimes) then to_ascii(md5((filename, ftimes, size)))
2049 }. 2066 }.
2050 2067
2051 define Bool 2068 define Bool
@@ -2935,7 +2952,6 @@ define Maybe((String,Web_Site_Description)) @@ -2935,7 +2952,6 @@ define Maybe((String,Web_Site_Description))
2935 2952
2936 define One -> String make_generate_trust_ticket(DenialOfService dos). 2953 define One -> String make_generate_trust_ticket(DenialOfService dos).
2937 2954
2938 -  
2939 define One 2955 define One
2940 http_https_handler 2956 http_https_handler
2941 ( 2957 (
@@ -2944,14 +2960,17 @@ define One @@ -2944,14 +2960,17 @@ define One
2944 Bool is_https, 2960 Bool is_https,
2945 DenialOfService dos 2961 DenialOfService dos
2946 ) = 2962 ) =
  2963 + t0 <- (UTime)now;
2947 with start_time = (Int32)now, 2964 with start_time = (Int32)now,
2948 sttm <- start_time; 2965 sttm <- start_time;
  2966 + println("Request time: " + format_http_date(start_time));
2949 if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then 2967 if dos is denial_of_service(mc_v,rld_v,hd_v,ad_v,ld_v,ra_v) then
2950 if remote_IP_address_and_port(connection.conn) is (ip_addr,port) then 2968 if remote_IP_address_and_port(connection.conn) is (ip_addr,port) then
2951 if read_request_line(connection,start_time+*rld_v,dos) is 2969 if read_request_line(connection,start_time+*rld_v,dos) is
2952 { 2970 {
2953 error(msg) then print(format(msg)), 2971 error(msg) then print(format(msg)),
2954 ok(request_line) then 2972 ok(request_line) then
  2973 + print_delta("read_request_line");
2955 if read_http_headers(connection,start_time+*hd_v,dos) is 2974 if read_http_headers(connection,start_time+*hd_v,dos) is
2956 { 2975 {
2957 error(msg) then print(format(msg)), 2976 error(msg) then print(format(msg)),
@@ -2959,16 +2978,21 @@ define One @@ -2959,16 +2978,21 @@ define One
2959 { 2978 {
2960 failure then unique, 2979 failure then unique,
2961 success(p) then if p is (host_name,desc) then 2980 success(p) then if p is (host_name,desc) then
  2981 + print_delta("get_site");
2962 if get_body_size(headers) is 2982 if get_body_size(headers) is
2963 { 2983 {
2964 error(msg) then log_journal_msg(desc,format(msg)), 2984 error(msg) then log_journal_msg(desc,format(msg)),
2965 ok(body_size) then 2985 ok(body_size) then
  2986 + print_delta("get_body_size");
2966 if read_http_body(connection,body_size,constant_byte_array(0,0),1000) is 2987 if read_http_body(connection,body_size,constant_byte_array(0,0),1000) is
2967 { 2988 {
2968 error(msg) then log_journal_msg(desc,format(msg)), 2989 error(msg) then log_journal_msg(desc,format(msg)),
2969 ok(body) then 2990 ok(body) then
  2991 + print_delta("before send_answer");
2970 send_answer(host_name, desc,connection.conn, request_line, headers, body, 2992 send_answer(host_name, desc,connection.conn, request_line, headers, body,
2971 - make_generate_trust_ticket(dos)) 2993 + make_generate_trust_ticket(dos));
  2994 + with duration = (UTime) now - *t0,
  2995 + println("Request duration: " + utime_to_string(duration))
2972 } 2996 }
2973 } 2997 }
2974 } 2998 }