From: adash Date: Wed, 8 Nov 2006 02:38:26 +0000 (+0000) Subject: Bug fixed for native read errors , new errors in native write X-Git-Tag: preEdgeChange~752 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=68234dd1903c4d3cbad16aeb5876a39392b76663;p=IRC.git Bug fixed for native read errors , new errors in native write TO Do fix it --- diff --git a/Robust/src/Tests/WebServerExample.java b/Robust/src/Tests/WebServerExample.java index ee714e4e..09ed26d1 100644 --- a/Robust/src/Tests/WebServerExample.java +++ b/Robust/src/Tests/WebServerExample.java @@ -14,21 +14,22 @@ task Startup(StartupObject s {initialstate}) { //Listen for a request and accept request task AcceptConnection(ServerSocket ss{SocketPending}) { System.printString("W> Waiting for connection...\n"); - WebServerSocket web = new WebServerSocket() {!WritePending, !TransPending}; + WebServerSocket web = new WebServerSocket() {!WritePending, !TransPending, WebInitialize}; ss.accept(web); System.printString("W> Connected... \n"); } // Process the incoming http request -task ProcessRequest(WebServerSocket web{IOPending}) { +task ProcessRequest(WebServerSocket web{IOPending && WebInitialize}) { +//task ProcessRequest(WebServerSocket web{IOPending}) { System.printString("W> Inside ProcessRequest... \n"); web.clientrequest(); if(web.checktrans()==false) // Not special transaction , do normal filesending - taskexit(web {WritePending, LogPending}); //Sets the WritePending and LogPending flag true + taskexit(web {WritePending, LogPending,!WebInitialize}); //Sets the WritePending and LogPending flag true else // Invoke special inventory transaction - taskexit(web {TransPending, LogPending}); + taskexit(web {TransPending, LogPending,!WebInitialize}); } //Do the WriteIO on server socket and send the requested file to Client @@ -104,7 +105,7 @@ task Transaction(WebServerSocket web{TransPending}, Inventory inventorylist{Tran } else { /* Error */ System.printString("T > Error - Unknown transaction\n"); } - //Invoke operations + //Invoke close operations web.close(); taskexit(web {!TransPending}); } diff --git a/Robust/src/Tests/WebServerSocket.java b/Robust/src/Tests/WebServerSocket.java index b8abe511..330764f6 100644 --- a/Robust/src/Tests/WebServerSocket.java +++ b/Robust/src/Tests/WebServerSocket.java @@ -3,6 +3,8 @@ public class WebServerSocket extends Socket { flag LogPending; flag WritePending; flag TransPending; + flag WebInitialize; + //Filename requested by the client String filename; String[] parsed; @@ -61,12 +63,9 @@ public class WebServerSocket extends Socket { byte b1[] = new byte[1024]; read(b1);//Read client request from web server socket String clientreq = new String(b1); - //System.printString(clientreq); - //System.printString("\n"); int index = clientreq.indexOf('/');//Parse the GET client request to find filename int end = clientreq.indexOf('H'); filename = clientreq.subString((index+1), (end-1)); - //System.printString(filename); System.printString("\n"); return 0; } @@ -81,7 +80,10 @@ public class WebServerSocket extends Socket { } } - + //Parse for the substrings in the filename and use it to obtain the + //kind of operation, name of item, quantity of item, price of item + //e.g. trans_add_car_2_10000 is the filename + //store in the parsed[] string , add,car,2,1000 public int parseTransaction(){ int start = filename.indexOf('_'); String s = filename.subString(start+1);