From 093d507a39c5b4c66b11ef7f34285c35b52c4629 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 6 Nov 2007 07:21:39 +0000 Subject: [PATCH] more code --- .../Jhttpp2/Java/Jhttpp2ClientInputStream.java | 10 ++++++++-- .../Benchmarks/Jhttpp2/Java/Jhttpp2HTTPSession.java | 8 ++++++-- Robust/src/ClassLibrary/SocketInputStream.java | 2 +- Robust/src/Runtime/thread.c | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2ClientInputStream.java b/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2ClientInputStream.java index 10562fd4..39b229bd 100755 --- a/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2ClientInputStream.java +++ b/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2ClientInputStream.java @@ -80,7 +80,8 @@ public class Jhttpp2ClientInputStream extends BufferedInputStream { content_len = 0; boolean start_line=true; buf = getLine(); // reads the first line - + if (buf==null) + return -2; boolean cnt=true; while (lread>2&&cnt) { if (start_line) { @@ -172,6 +173,8 @@ public class Jhttpp2ClientInputStream extends BufferedInputStream { header_length+=lread; } buf=getLine(); + if (buf==null) + return -2; } rq+=buf; //adds last line (should be an empty line) to the header String header_length+=lread; @@ -211,8 +214,11 @@ public class Jhttpp2ClientInputStream extends BufferedInputStream { if (l!=-1) { line+=(char)l; lread++; - } else + } else { cnt=false; + if (!line.equals("")) + return null; + } } return line; } diff --git a/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2HTTPSession.java b/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2HTTPSession.java index 5dde6bcf..66e80c43 100644 --- a/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2HTTPSession.java +++ b/Robust/src/Benchmarks/Jhttpp2/Java/Jhttpp2HTTPSession.java @@ -190,12 +190,14 @@ public class Jhttpp2HTTPSession extends Thread { } /** the main routine, where it all happens */ - public void handleRequest() { + public int handleRequest() { InetAddress remote_host; Jhttpp2Read remote_in=null; int remote_port; byte[] b=new byte[65536]; int numread=in.read(b); + if (numread==-2) + return -1; boolean cnt=true; while(cnt) { // with this loop we support persistent connections if (numread==-1) { // -1 signals an error @@ -261,6 +263,8 @@ public class Jhttpp2HTTPSession extends Thread { if (cnt) { while(cnt) { // reads data from the client numread=in.read(b); + if (numread==-2) + return -1; if (numread!=-1) { HTTP_out.write(b, 0, numread); HTTP_out.flush(); @@ -273,7 +277,7 @@ public class Jhttpp2HTTPSession extends Thread { out.flush(); if (!notConnected() && remote_in != null) remote_in.close(); // close Jhttpp2Read thread - return; + return 0; } /** connects to the given host and port */ public void connect(InetAddress host,int port) { diff --git a/Robust/src/ClassLibrary/SocketInputStream.java b/Robust/src/ClassLibrary/SocketInputStream.java index be7b58c3..43e4ed89 100644 --- a/Robust/src/ClassLibrary/SocketInputStream.java +++ b/Robust/src/ClassLibrary/SocketInputStream.java @@ -7,7 +7,7 @@ public class SocketInputStream extends InputStream { public int read() { byte[] x=new byte[1]; int len=s.read(x); - if (len==0) + if (len<=0) return -1; else return x[0]; } diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 70cd784d..235b4ed9 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -66,6 +66,7 @@ void initializethreads() { sigaction(SIGBUS,&sig,0); sigaction(SIGSEGV,&sig,0); sigaction(SIGFPE,&sig,0); + signal(SIGPIPE, SIG_IGN); } #ifdef THREADS -- 2.34.1