From 23b3702053cc21173f99077a2eb051256ef9fa78 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Thu, 8 Nov 2007 23:32:44 +0000 Subject: [PATCH] small changes to chase down why it was slow --- .../Benchmarks/Jhttpp2/BR/Jhttpp2Task.java | 36 ++++++++++--------- .../src/Benchmarks/Jhttpp2/BR/MySocket.java | 7 ++++ 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 Robust/src/Benchmarks/Jhttpp2/BR/MySocket.java diff --git a/Robust/src/Benchmarks/Jhttpp2/BR/Jhttpp2Task.java b/Robust/src/Benchmarks/Jhttpp2/BR/Jhttpp2Task.java index bd20efd4..37b2f7bb 100644 --- a/Robust/src/Benchmarks/Jhttpp2/BR/Jhttpp2Task.java +++ b/Robust/src/Benchmarks/Jhttpp2/BR/Jhttpp2Task.java @@ -5,16 +5,16 @@ task start(StartupObject s{initialstate}) { task acceptconnection(ServerSocket ss{SocketPending}) { tag t=new tag(connection); - Socket s=ss.accept(t); + MySocket ms=new MySocket(){}{t}; + ss.accept(ms); Jhttpp2HTTPSession js=new Jhttpp2HTTPSession() {first}{t}; Jhttpp2ClientInputStream jcis=new Jhttpp2ClientInputStream() {}{t}; } -task requestfirst(Jhttpp2HTTPSession session {first}{connection tc}, Jhttpp2ClientInputStream jcis {}{connection tc}, Socket socket {IOPending}{connection tc}) { +task requestfirst(Jhttpp2HTTPSession session {first}{connection tc}, Jhttpp2ClientInputStream jcis {}{connection tc}, MySocket socket {IOPending}{connection tc}) { byte[] buf=new byte[10000]; int length=socket.read(buf); String str=new String(buf, 0, length); - System.printString("["+str+"]\n"); if (session.request!=null) { str=session.request.concat(str); } @@ -32,20 +32,19 @@ task requestfirst(Jhttpp2HTTPSession session {first}{connection tc}, Jhttpp2Clie } } -task request(Jhttpp2HTTPSession session {}{connection tc}, Jhttpp2ClientInputStream jcis {}{connection tc}, Socket socket {IOPending}{connection tc}, optional Request rold{!chained}{connection tc}) { +task request(Jhttpp2HTTPSession session {!first}{connection tc}, Jhttpp2ClientInputStream jcis {}{connection tc}, MySocket socket {IOPending}{connection tc}, optional Request rold{!chained}{connection tc}) { byte[] buf=new byte[10000]; int length=socket.read(buf); - System.printString("length="+length+"\n"); if (session.request!=null) System.printString(session.request+"\n"); if (length==0) { + socket.close(); taskexit; } else if (length < 0 ) { System.printString("ERROR\n"); taskexit; } String str=new String(buf, 0, length); - System.printString("["+str+"]\n"); if (session.request!=null) { str=session.request.concat(str); @@ -57,7 +56,6 @@ task request(Jhttpp2HTTPSession session {}{connection tc}, Jhttpp2ClientInputStr session.request=str; taskexit; } else { - System.printString("new Request\n"); session.request=str.substring(r.length(), str.length()); if (session.request.length()>0) taskexit(session{more}, rold{chained}{ct}); @@ -90,9 +88,14 @@ task sendfirst(Request r{first&&!processed}{connection tc}) { taskexit(r{processed}); } -task sendnext(optional Request rprev{received&&!done}{chained ct}, Request r{!processed}{chained ct}) { +task sendnext(optional Request rprev{received&&!done}{chained ct}, Request r{!processed&&!first}{chained ct}) { r.parseRequest(); - r.connect(); + if (isavailable(rprev)&&rprev.remote_host_name!=null&& + rprev.remote_host_name.equals(r.remote_host_name)&&rprev.port==r.port) { + r.fd=rprev.fd; + r.nativeBindFD(r.fd); + } else + r.connect(); r.sendRequest(); taskexit(r{processed}, rprev{done}); } @@ -103,6 +106,9 @@ task recvreq(Request r{processed&&!received&&IOPending}) { if (length==0) { //Done taskexit(r{received}); + } else if (length<0) { + r.close(); + taskexit(r{received}); } String str=new String(buf, 0, length); if (r.response!=null) { @@ -131,7 +137,7 @@ task recvreq(Request r{processed&&!received&&IOPending}) { lastindex=nextindex; } if (bytes>0) { - if ((lastindex+bytes)