freelist=NULL;
}
-void addtransaction(unsigned int oid, struct transrecord * trans) {
+void addtransaction(unsigned int oid) {
struct readerlist * rl;
int i;
if (pthread_mutex_trylock(&aborttablelock)!=0)
freelist=rl->next;
memset(rl,0, sizeof(struct readerlist));
}
- chashInsert(rl, oid, rl);
+ chashInsert(aborttable, oid, rl);
}
while(rl->numreaders==READERSIZE) {
if (rl->next!=NULL)
}
}
rl->numreaders++;
- for(i=0;i<READERSIZE;i++) {
+ for(i=0; i<READERSIZE; i++) {
if (rl->array[i]==NULL) {
- rl->array[i]=trans;
+ rl->array[i]=&t_abort;
pthread_mutex_unlock(&aborttablelock);
return;
}
void removetransaction(unsigned int oidarray[], unsigned int numoids) {
int i,j;
pthread_mutex_lock(&aborttablelock);
- for(i=0;i<numoids;i++) {
+ for(i=0; i<numoids; i++) {
unsigned int oid=oidarray[i];
- struct readerlist *rl=chashRemove2(table, oid);
+ struct readerlist *rl=chashRemove2(aborttable, oid);
struct readerlist *tmp;
+ if (rl==NULL)
+ continue;
do {
- count=rl->numreaders;
- for(int j=0;count;j++) {
- struct transrecord *trans=rl->array[j];
- if (trans!=NULL) {
- trans->abort=1;//It's okay to set our own abort flag...it is
- //too late to abort us
+ int count=rl->numreaders;
+ int j;
+ for(j=0; count; j++) {
+ int *t_abort=rl->array[j];
+ if (t_abort!=NULL) {
+ *t_abort=1; //It's okay to set our own abort flag...it is
+ //too late to abort us
count--;
}
}
pthread_mutex_unlock(&aborttablelock);
}
-void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids, struct transrecord * trans) {
+void removethisreadtransaction(unsigned char* oidverread, unsigned int numoids) {
int i,j;
pthread_mutex_lock(&aborttablelock);
- for(i=0;i<numoids;i++) {
+ for(i=0; i<numoids; i++) {
unsigned int oid=*((unsigned int *)oidverread);
struct readerlist * rl=chashSearch(aborttable, oid);
struct readerlist *first=rl;
oidverread+=(sizeof(unsigned int)+sizeof(unsigned short));
- while(1) {
- for(j=0;j<READERSIZE;j++) {
- if (rl->array[j]==trans) {
+ while(rl!=NULL) {
+ for(j=0; j<READERSIZE; j++) {
+ if (rl->array[j]==&t_abort) {
rl->array[j]=NULL;
if ((--rl->numreaders)==0) {
if (first==rl) {
- chashRemove2(table, oid);
- if (rl->next!=NULL)
- chashInsert(table, oid, rl->next);
+ chashRemove2(aborttable, oid);
+ if (rl->next!=NULL)
+ chashInsert(aborttable, oid, rl->next);
rl->next=freelist;
freelist=rl;
} else {
first=rl;
rl=rl->next;
}
- nextitem:
+nextitem:
+ ;
}
pthread_mutex_unlock(&aborttablelock);
}
-void removetransactionhash(chashtable_t *table, struct transrecord *trans) {
- chashlistnode_t *ptr=table->table;
- unsigned int size=table->size;
+void removetransactionhash() {
+ chashlistnode_t *ptr=c_table;
int i,j;
pthread_mutex_lock(&aborttablelock);
- for(i=0;i<size;i++) {
+ for(i=0; i<c_size; i++) {
chashlistnode_t *curr=&ptr[i];
do {
unsigned int oid=curr->key;
break;
struct readerlist * rl=chashSearch(aborttable, oid);
struct readerlist *first=rl;
- while(1) {
- for(j=0;j<READERSIZE;j++) {
- if (rl->array[j]==trans) {
+ while(rl!=NULL) {
+ for(j=0; j<READERSIZE; j++) {
+ if (rl->array[j]==&t_abort) {
rl->array[j]=NULL;
if ((--rl->numreaders)==0) {
if (first==rl) {
- chashRemove2(table, oid);
- if (rl->next!=NULL)
- chashInsert(table, oid, rl->next);
+ chashRemove2(aborttable, oid);
+ if (rl->next!=NULL)
+ chashInsert(aborttable, oid, rl->next);
rl->next=freelist;
freelist=rl;
} else {
first=rl;
rl=rl->next;
}
- nextitem:
+nextitem:
curr=curr->next;
} while(curr!=NULL);
}
}
-void removethistransaction(unsigned int oidarray[], unsigned int numoids, struct transrecord * trans) {
+void removethistransaction(unsigned int oidarray[], unsigned int numoids) {
int i,j;
pthread_mutex_lock(&aborttablelock);
- for(i=0;i<numoids;i++) {
+ for(i=0; i<numoids; i++) {
unsigned int oid=oidarray[i];
struct readerlist * rl=chashSearch(aborttable, oid);
-
+
struct readerlist *first=rl;
- while(1) {
- for(j=0;j<READERSIZE;j++) {
- if (rl->array[j]==trans) {
+ while(rl!=NULL) {
+ for(j=0; j<READERSIZE; j++) {
+ if (rl->array[j]==&t_abort) {
rl->array[j]=NULL;
if ((--rl->numreaders)==0) {
if (first==rl) {
- chashRemove2(table, oid);
- if (rl->next!=NULL)
- chashInsert(table, oid, rl->next);
+ chashRemove2(aborttable, oid);
+ if (rl->next!=NULL)
+ chashInsert(aborttable, oid, rl->next);
rl->next=freelist;
freelist=rl;
} else {
first=rl;
rl=rl->next;
}
- nextitem:
+nextitem:
+ ;
}
pthread_mutex_unlock(&aborttablelock);
}