From: jihoonl Date: Wed, 23 Jun 2010 06:47:09 +0000 (+0000) Subject: change X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=94896f7d9845a5c427f6b54c2a54fadf17a8e851;p=IRC.git change --- diff --git a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c index a35a55c5..b9d594c5 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/dstmserver.c @@ -869,6 +869,10 @@ int readClientReq(trans_commit_data_t *transinfo, int acceptfd) { return 0; } + pthread_mutex_lock(&translist_mutex); + transList = tlistInsertNode(transList,fixed.transid,TRYING_TO_COMMIT,TRYING_TO_COMMIT,fixed.epoch_num); + pthread_mutex_unlock(&translist_mutex); + /* Create an array of oids for modified objects */ oidmod = (unsigned int *) calloc(fixed.nummod, sizeof(unsigned int)); if (oidmod == NULL) { @@ -944,16 +948,13 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, if(timeout1 < 0 || timeout2 < 0) { // timeout. failed to receiving data from coordinator control = DECISION_LOST; } - - pthread_mutex_lock(&translist_mutex); - transList = tlistInsertNode(transList,fixed->transid,control,TRYING_TO_COMMIT,epoch_num); - pthread_mutex_unlock(&translist_mutex); pthread_mutex_lock(&translist_mutex); tNode = tlistSearch(transList,fixed->transid); pthread_mutex_unlock(&translist_mutex); // check if it is allowed to commit + tNode->decision = control; do { tNode->status = TRANS_INPROGRESS; if(okCommit != TRANS_BEFORE) { @@ -969,7 +970,7 @@ int processClientReq(fixed_data_t *fixed, trans_commit_data_t *transinfo, } } else { - tNode->status = TRYING_TO_COMMIT; + tNode->status = TRANS_WAIT; printf("%s -> Waiting!! \ttransID : %u decision : %d status : %d \n",__func__,tNode->transid,tNode->decision,tNode->status); sleep(3); randomdelay(); @@ -1864,10 +1865,12 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num) while(walker) { // locking - while(walker->status == TRANS_INPROGRESS) { - printf("%s ->transid : %u - decision %d Status : %d Waitflag = %d\n",__func__,walker->transid,walker->decision,walker->status,TRANS_FLAG); - if(inspectEpoch(walker->epoch_num,"stopTrans_Before") < 0) - return -1; + while(walker->status != TRANS_WAIT && tlistSearch(transList,walker->transid) != NULL) { + printf("%s -> BEFORE transid : %u - decision %d Status : %d \n",__func__,walker->transid,walker->decision,walker->status); + if(inspectEpoch(epoch_num,"stopTrans_Before") < 0) { + printf("%s -> Higher Epoch is seen, walker->epoch = %u currentEpoch = %u\n",__func__,epoch_num,currentEpoch); + return -1; + } sleep(3); } walker = walker->next; @@ -1889,13 +1892,15 @@ int stopTransactions(int TRANS_FLAG,unsigned int epoch_num) printf("%s -> okCommit = %d\n",__func__,okCommit); walker = transList->head; while(walker){ - printf("%s ->transid : %u - decision %d Status : %d epoch = %u current epoch : %u\n",__func__,walker->transid,walker->decision,walker->status,walker->epoch_num,currentEpoch); + printf("%s -> AFTER transid : %u - decision %d Status : %d epoch = %u current epoch : %u\n",__func__,walker->transid,walker->decision,walker->status,walker->epoch_num,currentEpoch); walker = walker->next; } pthread_mutex_unlock(&translist_mutex); - if(inspectEpoch(epoch_num,"stopTrans_Before") < 0) + if(inspectEpoch(epoch_num,"stopTrans_Before") < 0) { + printf("%s -> 222Higher Epoch is seen, walker->epoch = %u currentEpoch = %u\n",__func__,epoch_num,currentEpoch); return -1; + } sleep(3); }while(size != 0); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/trans.c b/Robust/src/Runtime/DSTM/interface_recovery/trans.c index 6be4344d..1ad2913a 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/trans.c +++ b/Robust/src/Runtime/DSTM/interface_recovery/trans.c @@ -1251,7 +1251,7 @@ int transCommit() { pthread_mutex_unlock(&recovery_mutex); pthread_mutex_lock(&translist_mutex); - transList = tlistInsertNode(transList,transID,TRYING_TO_COMMIT,TRYING_TO_COMMIT,epoch_num); + transList = tlistInsertNode(transList,transID,-3,TRYING_TO_COMMIT,epoch_num); tNode = tlistSearch(transList,transID); pthread_mutex_unlock(&translist_mutex); diff --git a/Robust/src/Runtime/DSTM/interface_recovery/translist.h b/Robust/src/Runtime/DSTM/interface_recovery/translist.h index 9364fb4d..9d2ab9da 100644 --- a/Robust/src/Runtime/DSTM/interface_recovery/translist.h +++ b/Robust/src/Runtime/DSTM/interface_recovery/translist.h @@ -14,6 +14,7 @@ #define TRANS_BEFORE 4 #define TRANS_INPROGRESS 5 #define TRANS_AFTER 6 +#define TRANS_WAIT 7 /* Status