Merge branch 'sandbox' (remove finalize())
authorBrian Norris <banorris@uci.edu>
Thu, 21 Jun 2012 09:11:15 +0000 (02:11 -0700)
committerBrian Norris <banorris@uci.edu>
Thu, 21 Jun 2012 09:11:27 +0000 (02:11 -0700)
Merge in the fix from Subramanian and me that eliminates the need for a
finalize() call. It was a kind of bug, in a way, that hopefully is fixed now...

1  2 
snapshot.cc

diff --combined snapshot.cc
index a50835d1cca27ecd2c28aac29e798791dce3f69c,eeeb58c995762ea9c01bf40f2515ef5f956b7d50..5fb1a85ebd4c4e633e1da3812b97776a893dccd8
@@@ -120,7 -120,6 +120,6 @@@ void createSharedLibrary()
        sTheRecord->mStackSize = STACK_SIZE_DEFAULT;
        sTheRecord->mIDToRollback = -1;
        sTheRecord->currSnapShotID = 0;
-       sTheRecord->mbFinalize = false;
  #endif
  }
  
@@@ -178,20 -177,26 +177,20 @@@ void initSnapShotLibrary(unsigned int n
        createSharedLibrary();
  
        //step 2 setup the stack context.
 -
 -      int alreadySwapped = 0;
 -      getcontext( &savedSnapshotContext );
 -      if( !alreadySwapped ){
 -              alreadySwapped = 1;
 -              ucontext_t currentContext, swappedContext, newContext;
 -              getcontext( &newContext );
 -              newContext.uc_stack.ss_sp = sTheRecord->mStackBase;
 -              newContext.uc_stack.ss_size = STACK_SIZE_DEFAULT;
 -              newContext.uc_link = &currentContext;
 -              makecontext( &newContext, entryPoint, 0 );
 -              swapcontext( &swappedContext, &newContext );
 -      }
 +      ucontext_t newContext;
 +      getcontext( &newContext );
 +      newContext.uc_stack.ss_sp = sTheRecord->mStackBase;
 +      newContext.uc_stack.ss_size = STACK_SIZE_DEFAULT;
 +      makecontext( &newContext, entryPoint, 0 );
 +      /* switch to a new entryPoint context, on a new stack */
 +      swapcontext(&savedSnapshotContext, &newContext);
  
        //add the code to take a snapshot here...
        //to return to user process, do a second swapcontext...
        pid_t forkedID = 0;
        snapshotid = sTheRecord->currSnapShotID;
        bool swapContext = false;
-       while( !sTheRecord->mbFinalize ){
+       while( true ){
                sTheRecord->currSnapShotID=snapshotid+1;
                forkedID = fork();
                if( 0 == forkedID ){
@@@ -305,14 -310,7 +304,7 @@@ void rollBack( snapshot_id theID )
                SSDEBUG("Invoked rollback");
                exit(EXIT_SUCCESS);
        }
+       sTheRecord->mIDToRollback = -1;
  #endif
  }
  
- /** The finalize method shuts down the snapshotting system.  */
- //Subramanian -- remove this function from the external interface and
- //have us call it internally
- void finalize(){
- #if !USE_MPROTECT_SNAPSHOT
-       sTheRecord->mbFinalize = true;
- #endif
- }