From 852d9ee7a367b75740844d4ec800c2613e3027ed Mon Sep 17 00:00:00 2001 From: jihoonl <jihoonl> Date: Wed, 3 Mar 2010 00:56:06 +0000 Subject: [PATCH] better duplicateLostObject --- .../Runtime/DSTM/interface_recovery/signal.c | 4 + .../Runtime/DSTM/interface_recovery/trans.c | 81 +++++++------------ 2 files changed, 33 insertions(+), 52 deletions(-) diff --git a/Robust/src/Runtime/DSTM/interface_recovery/signal.c b/Robust/src/Runtime/DSTM/interface_recovery/signal.c index 85445905..79917fd8 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/signal.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/signal.c @@ -48,6 +48,10 @@ void transStatsHandler(int sig, siginfo_t* info, void *context) { */ void transStatsHandler(int sig, siginfo_t* info, void *context) { +#ifdef RECOVERYSTATS + fflush(stdout); +#endif + #ifdef TRANSSTATS printf("****** Transaction Stats ******\n"); printf("myIpAddr = %x\n", myIpAddr); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/trans.c b/Robust/src/Runtime/DSTM/interface_recovery/trans.c index a544388e..b751584b 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/trans.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/trans.c @@ -2558,7 +2558,8 @@ void duplicateLostObjects(unsigned int mid){ //connect to these machines //go through their object store copying necessary (in a transaction) - int sd = 0, i, j, tmpNumLiveHosts = 0; + int i, j, tmpNumLiveHosts = 0; + int psd,bsd; /* duplicateLostObject example * Before M24 die, @@ -2573,67 +2574,43 @@ void duplicateLostObjects(unsigned int mid){ dupeSize = 0; - if(originalMid == myIpAddr) { // copy local machine's backup data, make it as primary data of backup machine. - dupeSize += duplicateLocalOriginalObjects(backupMid); // size of primary data - } - else if((sd = getSockWithLock(transPrefetchSockPool, originalMid)) < 0) { - printf("%s -> socket create error, attempt %d\n", __func__,j); + if(((psd = getSockWithLock(transPrefetchSockPool, originalMid)) < 0 ) || ((bsd = getSockWithLock(transPrefetchSockPool,backupMid)) <0)) { + printf("%s -> Socket create error\n",__func__); exit(0); - //usleep(1000); - } - else { // if original is not local - char duperequest; - duperequest = DUPLICATE_ORIGINAL; - send_data(sd, &duperequest, sizeof(char)); -#ifdef DEBUG - printf("%s-> SD : %d Sent DUPLICATE_ORIGINAL request to %s\n", __func__,sd,midtoIPString(originalMid)); -#endif - send_data(sd, &backupMid, sizeof(unsigned int)); + } - char response; - unsigned int receivedSize; - recv_data(sd, &response, sizeof(char)); - recv_data(sd, &receivedSize, sizeof(unsigned int)); +/* request for original */ + char duperequest; + duperequest = DUPLICATE_ORIGINAL; + send_data(psd, &duperequest, sizeof(char)); + send_data(psd, &backupMid, sizeof(unsigned int)); - dupeSize += receivedSize; // size of primary data - +/* request for backup */ + duperequest = DUPLICATE_BACKUP; + send_data(bsd, &duperequest, sizeof(char)); + send_data(bsd, &originalMid, sizeof(unsigned int)); -#ifdef DEBUG - printf("%s (DUPLICATE_ORIGINAL) -> Received %s\n", __func__,(response==DUPLICATION_COMPLETE)?"DUPLICATION_COMPLETE":"DUPLICATION_FAIL"); -#endif + char p_response,b_response; + unsigned int p_receivedSize,b_receivedSize; - freeSockWithLock(transPrefetchSockPool, originalMid, sd); - } + recv_data(psd, &p_response, sizeof(char)); + recv_data(psd, &p_receivedSize, sizeof(unsigned int)); - if(backupMid == myIpAddr) { // copy local machine's primary data, and make it as backup data of original machine. - dupeSize += duplicateLocalBackupObjects(originalMid); // size of backup data - } - else if((sd = getSockWithLock(transPrefetchSockPool, backupMid)) < 0) { - printf("updateLiveHosts(): socket create error, attempt %d\n", j); - exit(1); - } - else { - char duperequest; - duperequest = DUPLICATE_BACKUP; - send_data(sd, &duperequest, sizeof(char)); -#ifdef DEBUG - printf("%s-> SD : %d Sent DUPLICATE_BACKUP request to %s\n", __func__,sd,midtoIPString(backupMid)); -#endif - send_data(sd, &originalMid, sizeof(unsigned int)); + dupeSize += p_receivedSize; // size of primary data - char response; - unsigned int receivedSize; - recv_data(sd, &response, sizeof(char)); - recv_data(sd, &receivedSize, sizeof(unsigned int)); + recv_data(bsd, &b_response, sizeof(char)); + recv_data(bsd, &b_receivedSize, sizeof(unsigned int)); - dupeSize += receivedSize; // size of backup data + dupeSize += b_receivedSize; // size of backup data -#ifdef DEBUG - printf("%s (DUPLICATE_BACKUP) -> Received %s\n", __func__,(response==DUPLICATION_COMPLETE)?"DUPLICATION_COMPLETE":"DUPLICATION_FAIL"); -#endif + if(p_response != DUPLICATION_COMPLETE || b_response != DUPLICATION_COMPLETE) + { + printf("%s -> Duplication Fail\n",__func__); + exit(0); + } - freeSockWithLock(transPrefetchSockPool, backupMid, sd); - } + freeSockWithLock(transPrefetchSockPool, originalMid, psd); + freeSockWithLock(transPrefetchSockPool, backupMid, bsd); #ifdef RECOVERYSTATS fi = myrdtsc(); -- 2.34.1