bug fix
authorbdemsky <bdemsky>
Sat, 10 Nov 2007 23:16:05 +0000 (23:16 +0000)
committerbdemsky <bdemsky>
Sat, 10 Nov 2007 23:16:05 +0000 (23:16 +0000)
Robust/src/Benchmarks/Conglomerator/Tag/Lookup.java
Robust/src/Benchmarks/Conglomerator/Tag/Opt/WebServerExampleOpt.java
Robust/src/Runtime/checkpoint.c

index 8e35825364079479d48d7d57db1e6cf33eedea55..468276ca2704e4bf5220a147b94b2b35c6730b8a 100644 (file)
@@ -9,6 +9,28 @@ public class Lookup extends Socket {
     String data;
     String start;
     String end;
+
+    public void doLookup() {
+       String query="GET /"+url+" HTTP/1.1\r\nConnection: close\r\nHost:"+hostname+"\r\n\r\n";
+       connect(hostname, 80);
+       write(query.getBytes());
+    }
+
+    public boolean Receive() {
+       byte[] buffer=new byte[1024];
+       int numchars=read(buffer);
+       if (numchars<=0) {
+           fix();
+           close();
+           return true;
+       }
+       String str=new String(buffer, 0, numchars);
+       if (data==null) {
+           data=str;
+       } else
+           data=data+str;
+       return false;
+    }
                
     public void fix() {
        int istart=data.indexOf(start);
index 3d66d20f20d41e02e86f7944e8b518c6890ac45e..3b734724482d9abfe800b00a68bd0309b7001993 100644 (file)
@@ -1,7 +1,6 @@
 /* Startup object is generated with the initialstate flag set by the
  *  system to start the computation up */
 
-// Create New ServerSocket
 task Startup(StartupObject s {initialstate}) {
        ServerSocket ss = new ServerSocket(9000);
        Logger log = new Logger() {Initialize};
@@ -10,92 +9,46 @@ task Startup(StartupObject s {initialstate}) {
 }
 
 task LookupS(Stock l{initialstate}) {
-    String query="GET /"+l.url+" HTTP/1.1\r\nConnection: close\r\nHost:"+l.hostname+"\r\n\r\n";
-    l.connect(l.hostname, 80);
-    l.write(query.getBytes());
+    l.doLookup();
     taskexit(l{!initialstate, query});
 }
 
 task ReceiveQueryS(Stock l{query&&IOPending}) {
-    byte[] buffer=new byte[1024];
-    int numchars=l.read(buffer);
-    if (numchars<=0) {
-       l.fix();
-       l.close();
-       taskexit(l{!query,done}{});
-    }
-    String str=new String(buffer, 0, numchars);
-    if (l.data==null) {
-       l.data=str;
-    } else
-       l.data=l.data+str;
-    taskexit;
+    if (l.Receive()) taskexit(l{!query,done}{});
+    else taskexit;
 }
 
-task LookupG(Google l{initialstate}) {
-    String query="GET /"+l.url+" HTTP/1.1\r\nConnection: close\r\nHost:"+l.hostname+"\r\n\r\n";
-    l.connect(l.hostname, 80);
-    l.write(query.getBytes());
+task LookupW(Weather l{initialstate}) {
+    l.doLookup();
     taskexit(l{!initialstate, query});
 }
 
-task ReceiveQueryG(Google l{query&&IOPending}) {
-    byte[] buffer=new byte[1024];
-    int numchars=l.read(buffer);
-    if (numchars<=0) {
-       l.fix();
-       l.close();
-       taskexit(l{!query,done}{});
-    }
-    String str=new String(buffer, 0, numchars);
-    if (l.data==null) {
-       l.data=str;
-    } else
-       l.data=l.data+str;
-    taskexit;
+task ReceiveQueryW(Weather l{query&&IOPending}) {
+    if (l.Receive()) taskexit(l{!query,done}{});
+    else taskexit;
 }
 
-task LookupW(Weather l{initialstate}) {
-    String query="GET /"+l.url+" HTTP/1.1\r\nConnection: close\r\nHost:"+l.hostname+"\r\n\r\n";
-    l.connect(l.hostname, 80);
-    l.write(query.getBytes());
+task LookupG(Google l{initialstate}) {
+    l.doLookup();
     taskexit(l{!initialstate, query});
 }
 
-task ReceiveQueryW(Weather l{query&&IOPending}) {
-    byte[] buffer=new byte[1024];
-    int numchars=l.read(buffer);
-    if (numchars<=0) {
-       l.fix();
-       l.close();
-       taskexit(l{!query,done}{});
-    }
-    String str=new String(buffer, 0, numchars);
-    if (l.data==null) {
-       l.data=str;
-    } else
-       l.data=l.data+str;
-    taskexit;
+task ReceiveQueryG(Google l{query&&IOPending}) {
+    if (l.Receive()) taskexit(l{!query,done}{});
+    else taskexit;
 }
 
-
-
-//Listen for a request and accept request 
 task AcceptConnection(ServerSocket ss{SocketPending}) {
-    // System.printString("W> Waiting for connection...\n");
     tag t=new tag(link);
     WebServerSocket web = new WebServerSocket() {!WritePending, !TransPending, WebInitialize}{t};
     MySocket ms=new MySocket(){}{t};
     ss.accept(ms);
-//     System.printString("W> Connected... \n");
 }
 
-// Process the incoming http request 
 task ProcessRequest(WebServerSocket web{WebInitialize}{link l}, MySocket s{IOPending}{link l}) {
        if (web.clientrequest(s)) {
            if(web.checktrans()==false)
-               // Not special transaction , do normal filesending      
-               taskexit(web {WritePending, LogPending,!WebInitialize}); //Sets the WritePending and LogPending flag true 
+               taskexit(web {WritePending, LogPending,!WebInitialize});
            else {
                Weather w=new Weather(){initialstate}{l};
                Google g=new Google(){initialstate}{l};
@@ -105,25 +58,18 @@ task ProcessRequest(WebServerSocket web{WebInitialize}{link l}, MySocket s{IOPen
        }
 }
 
-//Do the WriteIO on server socket and send the requested file to Client
 task SendFile(WebServerSocket web{WritePending}{link l}, MySocket s{}{link l}) {
-//     System.printString("W> Inside SendFile ... \n");
        web.sendfile(s);
        s.close();
        taskexit(web {!WritePending});
 }
 
-// Log the Client request
 task LogRequest(WebServerSocket web{LogPending}, Logger log{Initialize}) {
-//Task fired when both
-// LogPending and Initialize flags are true 
-//     System.printString("L > Inside logrequest\n");
        log.logrequest(web.filename);
        taskexit(web {!LogPending});
 }
 
-//Transaction on Inventory
-task Transaction(WebServerSocket web{TransPending}{link l}, optional Weather weather{done}{link l}, optional Google g{done}{link l}, MySocket s{}{link l}, optional Stock st{done}{link l}){ //Task for WebServerTransactions
+task Transaction(WebServerSocket web{TransPending}{link l}, optional Weather weather{done}{link l}, optional Google g{done}{link l}, MySocket s{}{link l}, optional Stock st{done}{link l}){
        web.httpresponse(s);
        s.write(("<html>").getBytes());
        if (isavailable(weather))
index 96019e384bf9357dba717dc7a3b346159c9ea12d..16aee0584f2a67cd78925a02ca1ae6eb792112b1 100644 (file)
@@ -298,8 +298,12 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
        int numptr=pointer[0];
        int i;
        void *flagptr;
+       int oldflag;
+       int currflag;
        if (hasflags[type]) {
          flagptr=(void *) (((int *)cpy)[2]);
+         oldflag=(((int *)cpy)[1]);
+         currflag=(((int *)ptr)[1]);
        }
        memcpy(cpy, ptr, size);
        for(i=1;i<=numptr;i++) {
@@ -317,7 +321,8 @@ void restorecheckpoint(int numparams, void ** original, void ** checkpoint, stru
        }
        if (hasflags[type]) {
          (((void **)cpy)[2])=flagptr;
-         flagorandinit(cpy, 0, 0xFFFFFFFF);
+         if (currflag!=oldflag)
+           flagorandinit(cpy, 0, 0xFFFFFFFF);
        }
       }
     }