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) {
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) {
}
}
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();
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;
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);