4 #include "machinepile.h"
9 #include "threadnotify.h"
16 #define PREFETCH_CACHE_SIZE 1048576 //1MB
17 #define CONFIG_FILENAME "dstm.conf"
19 /* Global Variables */
20 extern int classsize[];
21 objstr_t *prefetchcache; //Global Prefetch cache
22 pthread_mutex_t prefetchcache_mutex;// Mutex to lock Prefetch Cache
23 pthread_mutexattr_t prefetchcache_mutex_attr; /* Attribute for lock to make it a recursive lock */
24 extern pthread_mutex_t mainobjstore_mutex;// Mutex to lock main Object store
25 extern prehashtable_t pflookup; //Global Prefetch cache's lookup table
26 pthread_t wthreads[NUM_THREADS]; //Worker threads for working on the prefetch queue
27 pthread_t tPrefetch; /* Primary Prefetch thread that processes the prefetch queue */
28 extern objstr_t *mainobjstore;
29 unsigned int myIpAddr;
30 unsigned int *hostIpAddrs;
33 int myIndexInHostArray;
34 unsigned int oidsPerBlock;
38 sockPoolHashTable_t *transReadSockPool;
39 sockPoolHashTable_t *transPrefetchSockPool;
40 pthread_mutex_t notifymutex;
41 pthread_mutex_t atomicObjLock;
43 void printhex(unsigned char *, int);
44 plistnode_t *createPiles(transrecord_t *);
46 /*******************************
47 * Send and Recv function calls
48 *******************************/
49 void send_data(int fd , void *buf, int buflen) {
50 char *buffer = (char *)(buf);
54 numbytes = send(fd, buffer, size, MSG_NOSIGNAL);
64 void recv_data(int fd , void *buf, int buflen) {
65 char *buffer = (char *)(buf);
69 numbytes = recv(fd, buffer, size, 0);
79 int recv_data_errorcode(int fd , void *buf, int buflen) {
80 char *buffer = (char *)(buf);
84 numbytes = recv(fd, buffer, size, 0);
96 void printhex(unsigned char *ptr, int numBytes) {
98 for (i = 0; i < numBytes; i++) {
100 printf("0%x ", ptr[i]);
102 printf("%x ", ptr[i]);
108 inline int arrayLength(int *array) {
110 for(i=0 ;array[i] != -1; i++)
115 inline int findmax(int *array, int arraylength) {
118 for(i = 0; i < arraylength; i++){
126 /* This function is a prefetch call generated by the compiler that
127 * populates the shared primary prefetch queue*/
128 void prefetch(int ntuples, unsigned int *oids, unsigned short *endoffsets, short *arrayfields) {
129 /* Allocate for the queue node*/
130 int qnodesize = sizeof(int) + ntuples * (sizeof(unsigned short) + sizeof(unsigned int)) + endoffsets[ntuples - 1] * sizeof(short);
131 char * node= getmemory(qnodesize);
132 /* Set queue node values */
134 int top=endoffsets[ntuples-1];
135 *((int *)(node))=ntuples;
137 memcpy(node+len, oids, ntuples*sizeof(unsigned int));
138 memcpy(node+len+ntuples*sizeof(unsigned int), endoffsets, ntuples*sizeof(unsigned short));
139 memcpy(node+len+ntuples*(sizeof(unsigned int)+sizeof(short)), arrayfields, top*sizeof(short));
141 /* Lock and insert into primary prefetch queue */
145 /* This function starts up the transaction runtime. */
146 int dstmStartup(const char * option) {
147 pthread_t thread_Listen;
149 int master=option!=NULL && strcmp(option, "master")==0;
151 if (processConfigFile() != 0)
152 return 0; //TODO: return error value, cause main program to exit
158 //Initialize socket pool
159 transReadSockPool = createSockPool(transReadSockPool, 2*numHostsInSystem+1);
160 transPrefetchSockPool = createSockPool(transPrefetchSockPool, 2*numHostsInSystem+1);
166 pthread_attr_init(&attr);
167 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
168 pthread_create(&thread_Listen, &attr, dstmListen, NULL);
176 //TODO Use this later
177 void *pCacheAlloc(objstr_t *store, unsigned int size) {
183 while(ptr->next != NULL) {
184 /* check if store is empty */
185 if(((unsigned int)ptr->top - (unsigned int)ptr - sizeof(objstr_t) + size) <= ptr->size) {
200 /* This function initiates the prefetch thread A queue is shared
201 * between the main thread of execution and the prefetch thread to
202 * process the prefetch call Call from compiler populates the shared
203 * queue with prefetch requests while prefetch thread processes the
204 * prefetch requests */
209 //Create and initialize prefetch cache structure
210 prefetchcache = objstrCreate(PREFETCH_CACHE_SIZE);
212 /* Initialize attributes for mutex */
213 pthread_mutexattr_init(&prefetchcache_mutex_attr);
214 pthread_mutexattr_settype(&prefetchcache_mutex_attr, PTHREAD_MUTEX_RECURSIVE_NP);
216 pthread_mutex_init(&prefetchcache_mutex, &prefetchcache_mutex_attr);
218 pthread_mutex_init(¬ifymutex, NULL);
219 pthread_mutex_init(&atomicObjLock, NULL);
220 //Create prefetch cache lookup table
221 if(prehashCreate(HASH_SIZE, LOADFACTOR)) {
226 //Initialize primary shared queue
228 //Initialize machine pile w/prefetch oids and offsets shared queue
231 //Create the primary prefetch thread
233 retval=pthread_create(&tPrefetch, NULL, transPrefetch, NULL);
235 pthread_detach(tPrefetch);
238 /* This function stops the threads spawned */
241 pthread_cancel(tPrefetch);
242 for(t = 0; t < NUM_THREADS; t++)
243 pthread_cancel(wthreads[t]);
248 /* This functions inserts randowm wait delays in the order of msec
249 * Mostly used when transaction commits retry*/
256 req.tv_nsec = (long)(1000000 + (t%10000000)); //1-11 msec
257 nanosleep(&req, NULL);
261 /* This function initializes things required in the transaction start*/
262 transrecord_t *transStart() {
264 if((tmp = calloc(1, sizeof(transrecord_t))) == NULL){
265 printf("%s() Calloc error at line %d, %s\n", __func__, __LINE__, __FILE__);
268 tmp->cache = objstrCreate(1048576);
269 tmp->lookupTable = chashCreate(HASH_SIZE, LOADFACTOR);
271 tmp->revertlist=NULL;
276 /* This function finds the location of the objects involved in a transaction
277 * and returns the pointer to the object if found in a remote location */
278 objheader_t *transRead(transrecord_t *record, unsigned int oid) {
279 unsigned int machinenumber;
280 objheader_t *tmp, *objheader;
281 objheader_t *objcopy;
289 if((objheader = (objheader_t *)chashSearch(record->lookupTable, oid)) != NULL){
290 /* Search local transaction cache */
292 return &objheader[1];
296 } else if ((objheader = (objheader_t *) mhashSearch(oid)) != NULL) {
297 /* Look up in machine lookup table and copy into cache*/
298 GETSIZE(size, objheader);
299 size += sizeof(objheader_t);
300 objcopy = (objheader_t *) objstrAlloc(record->cache, size);
301 memcpy(objcopy, objheader, size);
302 /* Insert into cache's lookup table */
304 chashInsert(record->lookupTable, OID(objheader), objcopy);
310 } else if((tmp = (objheader_t *) prehashSearch(oid)) != NULL) {
311 /* Look up in prefetch cache */
313 size+=sizeof(objheader_t);
314 objcopy = (objheader_t *) objstrAlloc(record->cache, size);
315 memcpy(objcopy, tmp, size);
316 /* Insert into cache's lookup table */
317 chashInsert(record->lookupTable, OID(tmp), objcopy);
324 /* Get the object from the remote location */
325 if((machinenumber = lhashSearch(oid)) == 0) {
326 printf("Error: %s() No machine found for oid =% %s,%dx\n",__func__, machinenumber, __FILE__, __LINE__);
329 objcopy = getRemoteObj(record, machinenumber, oid);
331 if(objcopy == NULL) {
332 printf("Error: Object not found in Remote location %s, %d\n", __FILE__, __LINE__);
345 /* This function creates objects in the transaction record */
346 objheader_t *transCreateObj(transrecord_t *record, unsigned int size) {
347 objheader_t *tmp = (objheader_t *) objstrAlloc(record->cache, (sizeof(objheader_t) + size));
348 OID(tmp) = getNewOID();
352 chashInsert(record->lookupTable, OID(tmp), tmp);
355 return &tmp[1]; //want space after object header
361 /* This function creates machine piles based on all machines involved in a
362 * transaction commit request */
363 plistnode_t *createPiles(transrecord_t *record) {
365 plistnode_t *pile = NULL;
366 unsigned int machinenum;
367 objheader_t *headeraddr;
368 chashlistnode_t * ptr = record->lookupTable->table;
369 /* Represents number of bins in the chash table */
370 unsigned int size = record->lookupTable->size;
372 for(i = 0; i < size ; i++) {
373 chashlistnode_t * curr = &ptr[i];
374 /* Inner loop to traverse the linked list of the cache lookupTable */
375 while(curr != NULL) {
376 //if the first bin in hash table is empty
380 if ((headeraddr = chashSearch(record->lookupTable, curr->key)) == NULL) {
381 printf("Error: No such oid %s, %d\n", __FILE__, __LINE__);
385 //Get machine location for object id (and whether local or not)
386 if (STATUS(headeraddr) & NEW || (mhashSearch(curr->key) != NULL)) {
387 machinenum = myIpAddr;
388 } else if ((machinenum = lhashSearch(curr->key)) == 0) {
389 printf("Error: No such machine %s, %d\n", __FILE__, __LINE__);
393 //Make machine groups
394 pile = pInsert(pile, headeraddr, machinenum, record->lookupTable->numelements);
401 /* This function initiates the transaction commit process
402 * Spawns threads for each of the new connections with Participants
403 * and creates new piles by calling the createPiles(),
404 * Sends a transrequest() to each remote machines for objects found remotely
405 * and calls handleLocalReq() to process objects found locally */
406 int transCommit(transrecord_t *record) {
407 unsigned int tot_bytes_mod, *listmid;
408 plistnode_t *pile, *pile_ptr;
410 int pilecount, offset, threadnum = 0, trecvcount = 0;
412 char transid[TID_LEN];
413 trans_req_data_t *tosend;
414 trans_commit_data_t transinfo;
415 static int newtid = 0;
416 char treplyctrl = 0, treplyretry = 0; /* keeps track of the common response that needs to be sent */
418 thread_data_array_t *thread_data_array;
419 local_thread_data_array_t *ltdata;
425 thread_data_array = NULL;
428 /* Look through all the objects in the transaction record and make piles
429 * for each machine involved in the transaction*/
430 pile_ptr = pile = createPiles(record);
432 /* Create the packet to be sent in TRANS_REQUEST */
434 /* Count the number of participants */
435 pilecount = pCount(pile);
437 /* Create a list of machine ids(Participants) involved in transaction */
438 listmid = calloc(pilecount, sizeof(unsigned int));
439 pListMid(pile, listmid);
442 /* Initialize thread variables,
443 * Spawn a thread for each Participant involved in a transaction */
444 pthread_t thread[pilecount];
446 pthread_cond_t tcond;
447 pthread_mutex_t tlock;
448 pthread_mutex_t tlshrd;
450 thread_data_array = (thread_data_array_t *) calloc(pilecount, sizeof(thread_data_array_t));
452 ltdata = calloc(1, sizeof(local_thread_data_array_t));
454 thread_response_t rcvd_control_msg[pilecount]; /* Shared thread array that keeps track of responses of participants */
456 /* Initialize and set thread detach attribute */
457 pthread_attr_init(&attr);
458 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
459 pthread_mutex_init(&tlock, NULL);
460 pthread_cond_init(&tcond, NULL);
462 /* Process each machine pile */
463 while(pile != NULL) {
464 //Create transaction id
466 tosend = calloc(1, sizeof(trans_req_data_t));
467 tosend->f.control = TRANS_REQUEST;
468 sprintf(tosend->f.trans_id, "%x_%d", pile->mid, newtid);
469 tosend->f.mcount = pilecount;
470 tosend->f.numread = pile->numread;
471 tosend->f.nummod = pile->nummod;
472 tosend->f.numcreated = pile->numcreated;
473 tosend->f.sum_bytes = pile->sum_bytes;
474 tosend->listmid = listmid;
475 tosend->objread = pile->objread;
476 tosend->oidmod = pile->oidmod;
477 tosend->oidcreated = pile->oidcreated;
478 thread_data_array[threadnum].thread_id = threadnum;
479 thread_data_array[threadnum].mid = pile->mid;
480 thread_data_array[threadnum].buffer = tosend;
481 thread_data_array[threadnum].recvmsg = rcvd_control_msg;
482 thread_data_array[threadnum].threshold = &tcond;
483 thread_data_array[threadnum].lock = &tlock;
484 thread_data_array[threadnum].count = &trecvcount;
485 thread_data_array[threadnum].replyctrl = &treplyctrl;
486 thread_data_array[threadnum].replyretry = &treplyretry;
487 thread_data_array[threadnum].rec = record;
488 /* If local do not create any extra connection */
489 if(pile->mid != myIpAddr) { /* Not local */
491 rc = pthread_create(&thread[threadnum], &attr, transRequest, (void *) &thread_data_array[threadnum]);
494 perror("Error in pthread create\n");
495 pthread_cond_destroy(&tcond);
496 pthread_mutex_destroy(&tlock);
499 for (i = 0; i < threadnum; i++)
500 free(thread_data_array[i].buffer);
501 free(thread_data_array);
506 ltdata->tdata = &thread_data_array[threadnum];
507 ltdata->transinfo = &transinfo;
509 val = pthread_create(&thread[threadnum], &attr, handleLocalReq, (void *) ltdata);
512 perror("Error in pthread create\n");
513 pthread_cond_destroy(&tcond);
514 pthread_mutex_destroy(&tlock);
517 for (i = 0; i < threadnum; i++)
518 free(thread_data_array[i].buffer);
519 free(thread_data_array);
528 /* Free attribute and wait for the other threads */
529 pthread_attr_destroy(&attr);
531 for (i = 0; i < threadnum; i++) {
532 rc = pthread_join(thread[i], NULL);
535 printf("Error: return code from pthread_join() is %d\n", rc);
536 pthread_cond_destroy(&tcond);
537 pthread_mutex_destroy(&tlock);
540 for (j = i; j < threadnum; j++) {
541 free(thread_data_array[j].buffer);
545 free(thread_data_array[i].buffer);
549 pthread_cond_destroy(&tcond);
550 pthread_mutex_destroy(&tlock);
554 /* wait a random amount of time before retrying to commit transaction*/
556 free(thread_data_array);
561 /* Retry trans commit procedure during soft_abort case */
562 } while (treplyretry);
564 if(treplyctrl == TRANS_ABORT) {
566 objstrDelete(record->cache);
567 chashDelete(record->lookupTable);
569 free(thread_data_array);
572 } else if(treplyctrl == TRANS_COMMIT) {
574 objstrDelete(record->cache);
575 chashDelete(record->lookupTable);
577 free(thread_data_array);
581 //TODO Add other cases
582 printf("Error: in %s() THIS SHOULD NOT HAPPEN.....EXIT PROGRAM\n", __func__);
588 /* This function sends information involved in the transaction request
589 * to participants and accepts a response from particpants.
590 * It calls decideresponse() to decide on what control message
591 * to send next to participants and sends the message using sendResponse()*/
592 void *transRequest(void *threadarg) {
594 struct sockaddr_in serv_addr;
595 thread_data_array_t *tdata;
596 objheader_t *headeraddr;
597 char control, recvcontrol;
598 char machineip[16], retval;
600 tdata = (thread_data_array_t *) threadarg;
602 /* Send Trans Request */
603 if ((sd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
604 perror("Error in socket for TRANS_REQUEST\n");
607 bzero((char*) &serv_addr, sizeof(serv_addr));
608 serv_addr.sin_family = AF_INET;
609 serv_addr.sin_port = htons(LISTEN_PORT);
610 midtoIP(tdata->mid,machineip);
611 machineip[15] = '\0';
612 serv_addr.sin_addr.s_addr = inet_addr(machineip);
613 /* Open Connection */
614 if (connect(sd, (struct sockaddr *) &serv_addr, sizeof(struct sockaddr)) < 0) {
615 perror("Error in connect for TRANS_REQUEST\n");
620 /* Send bytes of data with TRANS_REQUEST control message */
621 send_data(sd, &(tdata->buffer->f), sizeof(fixed_data_t));
623 /* Send list of machines involved in the transaction */
625 int size=sizeof(unsigned int)*tdata->buffer->f.mcount;
626 send_data(sd, tdata->buffer->listmid, size);
629 /* Send oids and version number tuples for objects that are read */
631 int size=(sizeof(unsigned int)+sizeof(unsigned short))*tdata->buffer->f.numread;
632 send_data(sd, tdata->buffer->objread, size);
635 /* Send objects that are modified */
636 for(i = 0; i < tdata->buffer->f.nummod ; i++) {
638 headeraddr = chashSearch(tdata->rec->lookupTable, tdata->buffer->oidmod[i]);
639 GETSIZE(size,headeraddr);
640 size+=sizeof(objheader_t);
641 send_data(sd, headeraddr, size);
644 /* Read control message from Participant */
645 recv_data(sd, &control, sizeof(char));
646 recvcontrol = control;
648 /* Update common data structure and increment count */
649 tdata->recvmsg[tdata->thread_id].rcv_status = recvcontrol;
651 /* Lock and update count */
652 /* Thread sleeps until all messages from pariticipants are received by coordinator */
653 pthread_mutex_lock(tdata->lock);
655 (*(tdata->count))++; /* keeps track of no of messages received by the coordinator */
657 /* Wake up the threads and invoke decideResponse (once) */
658 if(*(tdata->count) == tdata->buffer->f.mcount) {
659 decideResponse(tdata);
660 pthread_cond_broadcast(tdata->threshold);
662 pthread_cond_wait(tdata->threshold, tdata->lock);
664 pthread_mutex_unlock(tdata->lock);
666 /* Send the final response such as TRANS_COMMIT or TRANS_ABORT t
667 * to all participants in their respective socket */
668 if (sendResponse(tdata, sd) == 0) {
669 printf("sendResponse returned error %s,%d\n", __FILE__, __LINE__);
674 recv_data((int)sd, &control, sizeof(char));
676 if(control == TRANS_UNSUCESSFUL) {
677 //printf("DEBUG-> TRANS_ABORTED\n");
678 } else if(control == TRANS_SUCESSFUL) {
679 //printf("DEBUG-> TRANS_SUCCESSFUL\n");
681 //printf("DEBUG-> Error: Incorrect Transaction End Message %d\n", control);
684 /* Close connection */
689 /* This function decides the reponse that needs to be sent to
690 * all Participant machines after the TRANS_REQUEST protocol */
691 void decideResponse(thread_data_array_t *tdata) {
693 int i, transagree = 0, transdisagree = 0, transsoftabort = 0; /* Counters to formulate decision of what
696 for (i = 0 ; i < tdata->buffer->f.mcount; i++) {
697 control = tdata->recvmsg[i].rcv_status; /* tdata: keeps track of all participant responses
698 written onto the shared array */
701 printf("Participant sent unknown message in %s, %d\n", __FILE__, __LINE__);
702 /* treat as disagree, pass thru */
711 case TRANS_SOFT_ABORT:
717 if(transdisagree > 0) {
719 *(tdata->replyctrl) = TRANS_ABORT;
720 *(tdata->replyretry) = 0;
721 /* clear objects from prefetch cache */
722 for (i = 0; i < tdata->buffer->f.numread; i++)
723 prehashRemove(*((unsigned int *)(((char *)tdata->buffer->objread) + (sizeof(unsigned int) + sizeof(unsigned short))*i)));
724 for (i = 0; i < tdata->buffer->f.nummod; i++)
725 prehashRemove(tdata->buffer->oidmod[i]);
726 } else if(transagree == tdata->buffer->f.mcount){
728 *(tdata->replyctrl) = TRANS_COMMIT;
729 *(tdata->replyretry) = 0;
731 /* Send Abort in soft abort case followed by retry commiting transaction again*/
732 *(tdata->replyctrl) = TRANS_ABORT;
733 *(tdata->replyretry) = 1;
739 /* This function sends the final response to remote machines per
740 * thread in their respective socket id It returns a char that is only
741 * needed to check the correctness of execution of this function
742 * inside transRequest()*/
744 char sendResponse(thread_data_array_t *tdata, int sd) {
745 int n, size, sum, oidcount = 0, control;
746 char *ptr, retval = 0;
747 unsigned int *oidnotfound;
749 control = *(tdata->replyctrl);
750 send_data(sd, &control, sizeof(char));
752 //TODO read missing objects during object migration
753 /* If response is a soft abort due to missing objects at the
754 Participant's side */
756 /* If the decided response is TRANS_ABORT */
757 if(*(tdata->replyctrl) == TRANS_ABORT) {
758 retval = TRANS_ABORT;
759 } else if(*(tdata->replyctrl) == TRANS_COMMIT) {
760 /* If the decided response is TRANS_COMMIT */
761 retval = TRANS_COMMIT;
767 /* This function opens a connection, places an object read request to
768 * the remote machine, reads the control message and object if
769 * available and copies the object and its header to the local
772 void *getRemoteObj(transrecord_t *record, unsigned int mnum, unsigned int oid) {
774 struct sockaddr_in serv_addr;
778 void *objcopy = NULL;
780 int sd = getSock2(transReadSockPool, mnum);
781 char readrequest[sizeof(char)+sizeof(unsigned int)];
782 readrequest[0] = READ_REQUEST;
783 *((unsigned int *)(&readrequest[1])) = oid;
784 send_data(sd, readrequest, sizeof(readrequest));
786 /* Read response from the Participant */
787 recv_data(sd, &control, sizeof(char));
789 if (control==OBJECT_NOT_FOUND) {
792 /* Read object if found into local cache */
793 recv_data(sd, &size, sizeof(int));
794 objcopy = objstrAlloc(record->cache, size);
795 recv_data(sd, objcopy, size);
797 /* Insert into cache's lookup table */
798 chashInsert(record->lookupTable, oid, objcopy);
804 /* This function handles the local objects involved in a transaction
805 * commiting process. It also makes a decision if this local machine
806 * sends AGREE or DISAGREE or SOFT_ABORT to coordinator. Note
807 * Coordinator = local machine It wakes up the other threads from
808 * remote participants that are waiting for the coordinator's decision
809 * and based on common agreement it either commits or aborts the
810 * transaction. It also frees the memory resources */
812 void *handleLocalReq(void *threadarg) {
813 unsigned int *oidnotfound = NULL, *oidlocked = NULL;
814 local_thread_data_array_t *localtdata;
815 int objnotfound = 0, objlocked = 0;
816 int v_nomatch = 0, v_matchlock = 0, v_matchnolock = 0;
819 unsigned short version;
821 objheader_t *headptr;
823 localtdata = (local_thread_data_array_t *) threadarg;
825 /* Counters and arrays to formulate decision on control message to be sent */
826 oidnotfound = (unsigned int *) calloc((localtdata->tdata->buffer->f.numread + localtdata->tdata->buffer->f.nummod), sizeof(unsigned int));
827 oidlocked = (unsigned int *) calloc((localtdata->tdata->buffer->f.numread + localtdata->tdata->buffer->f.nummod), sizeof(unsigned int));
829 numread = localtdata->tdata->buffer->f.numread;
830 /* Process each oid in the machine pile/ group per thread */
831 for (i = 0; i < localtdata->tdata->buffer->f.numread + localtdata->tdata->buffer->f.nummod; i++) {
832 if (i < localtdata->tdata->buffer->f.numread) {
833 int incr = sizeof(unsigned int) + sizeof(unsigned short);// Offset that points to next position in the objread array
835 oid = *((unsigned int *)(((char *)localtdata->tdata->buffer->objread) + incr));
836 version = *((unsigned short *)(((char *)localtdata->tdata->buffer->objread) + incr + sizeof(unsigned int)));
837 } else { // Objects Modified
839 headptr = (objheader_t *) chashSearch(localtdata->tdata->rec->lookupTable, localtdata->tdata->buffer->oidmod[i-numread]);
840 if (headptr == NULL) {
841 printf("Error: handleLocalReq() returning NULL %s, %d\n", __FILE__, __LINE__);
845 version = headptr->version;
847 /* Check if object is still present in the machine since the beginning of TRANS_REQUEST */
849 /* Save the oids not found and number of oids not found for later use */
850 if ((mobj = mhashSearch(oid)) == NULL) { /* Obj not found */
851 /* Save the oids not found and number of oids not found for later use */
852 oidnotfound[objnotfound] = oid;
854 } else { /* If Obj found in machine (i.e. has not moved) */
855 /* Check if Obj is locked by any previous transaction */
856 if (test_and_set(STATUSPTR(mobj))) {
857 if (version == ((objheader_t *)mobj)->version) { /* If locked then match versions */
859 } else {/* If versions don't match ...HARD ABORT */
861 /* Send TRANS_DISAGREE to Coordinator */
862 localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE;
866 /* Save all object oids that are locked on this machine during this transaction request call */
867 oidlocked[objlocked] = OID(((objheader_t *)mobj));
869 if (version == ((objheader_t *)mobj)->version) { /* Check if versions match */
871 } else { /* If versions don't match ...HARD ABORT */
873 /* Send TRANS_DISAGREE to Coordinator */
874 localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_DISAGREE;
879 /* Condition to send TRANS_AGREE */
880 if(v_matchnolock == localtdata->tdata->buffer->f.numread + localtdata->tdata->buffer->f.nummod) {
881 localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_AGREE;
883 /* Condition to send TRANS_SOFT_ABORT */
884 if((v_matchlock > 0 && v_nomatch == 0) || (objnotfound > 0 && v_nomatch == 0)) {
885 localtdata->tdata->recvmsg[localtdata->tdata->thread_id].rcv_status = TRANS_SOFT_ABORT;
888 /* Fill out the trans_commit_data_t data structure. This is required for a trans commit process
889 * if Participant receives a TRANS_COMMIT */
890 localtdata->transinfo->objlocked = oidlocked;
891 localtdata->transinfo->objnotfound = oidnotfound;
892 localtdata->transinfo->modptr = NULL;
893 localtdata->transinfo->numlocked = objlocked;
894 localtdata->transinfo->numnotfound = objnotfound;
895 /* Lock and update count */
896 //Thread sleeps until all messages from pariticipants are received by coordinator
897 pthread_mutex_lock(localtdata->tdata->lock);
898 (*(localtdata->tdata->count))++; /* keeps track of no of messages received by the coordinator */
900 /* Wake up the threads and invoke decideResponse (once) */
901 if(*(localtdata->tdata->count) == localtdata->tdata->buffer->f.mcount) {
902 decideResponse(localtdata->tdata);
903 pthread_cond_broadcast(localtdata->tdata->threshold);
905 pthread_cond_wait(localtdata->tdata->threshold, localtdata->tdata->lock);
907 pthread_mutex_unlock(localtdata->tdata->lock);
908 if(*(localtdata->tdata->replyctrl) == TRANS_ABORT){
909 if(transAbortProcess(localtdata) != 0) {
910 printf("Error in transAbortProcess() %s,%d\n", __FILE__, __LINE__);
913 } else if(*(localtdata->tdata->replyctrl) == TRANS_COMMIT) {
914 if(transComProcess(localtdata) != 0) {
915 printf("Error in transComProcess() %s,%d\n", __FILE__, __LINE__);
920 if (localtdata->transinfo->objlocked != NULL) {
921 free(localtdata->transinfo->objlocked);
923 if (localtdata->transinfo->objnotfound != NULL) {
924 free(localtdata->transinfo->objnotfound);
930 /* This function completes the ABORT process if the transaction is aborting */
931 int transAbortProcess(local_thread_data_array_t *localtdata) {
933 unsigned int *objlocked;
936 numlocked = localtdata->transinfo->numlocked;
937 objlocked = localtdata->transinfo->objlocked;
939 for (i = 0; i < numlocked; i++) {
940 if((header = mhashSearch(objlocked[i])) == NULL) {
941 printf("mhashsearch returns NULL at %s, %d\n", __FILE__, __LINE__);
944 UnLock(STATUSPTR(header));
950 /*This function completes the COMMIT process is the transaction is commiting*/
951 int transComProcess(local_thread_data_array_t *localtdata) {
952 objheader_t *header, *tcptr;
953 int i, nummod, tmpsize, numcreated, numlocked;
954 unsigned int *oidmod, *oidcreated, *oidlocked;
957 nummod = localtdata->tdata->buffer->f.nummod;
958 oidmod = localtdata->tdata->buffer->oidmod;
959 numcreated = localtdata->tdata->buffer->f.numcreated;
960 oidcreated = localtdata->tdata->buffer->oidcreated;
961 numlocked = localtdata->transinfo->numlocked;
962 oidlocked = localtdata->transinfo->objlocked;
964 for (i = 0; i < nummod; i++) {
965 if((header = (objheader_t *) mhashSearch(oidmod[i])) == NULL) {
966 printf("Error: transComProcess() mhashsearch returns NULL at %s, %d\n", __FILE__, __LINE__);
969 /* Copy from transaction cache -> main object store */
970 if ((tcptr = ((objheader_t *) chashSearch(localtdata->tdata->rec->lookupTable, oidmod[i]))) == NULL) {
971 printf("Error: transComProcess() chashSearch returned NULL at %s, %d\n", __FILE__, __LINE__);
974 GETSIZE(tmpsize, header);
975 char *tmptcptr = (char *) tcptr;
976 memcpy((char*)header+sizeof(objheader_t), (char *)tmptcptr+ sizeof(objheader_t), tmpsize);
977 header->version += 1;
978 if(header->notifylist != NULL) {
979 notifyAll(&header->notifylist, OID(header), header->version);
982 /* If object is newly created inside transaction then commit it */
983 for (i = 0; i < numcreated; i++) {
984 if ((header = ((objheader_t *) chashSearch(localtdata->tdata->rec->lookupTable, oidcreated[i]))) == NULL) {
985 printf("Error: transComProcess() chashSearch returned NULL for oid = %x at %s, %d\n", oidcreated[i], __FILE__, __LINE__);
988 GETSIZE(tmpsize, header);
989 tmpsize += sizeof(objheader_t);
990 pthread_mutex_lock(&mainobjstore_mutex);
991 if ((ptrcreate = objstrAlloc(mainobjstore, tmpsize)) == NULL) {
992 printf("Error: transComProcess() failed objstrAlloc %s, %d\n", __FILE__, __LINE__);
993 pthread_mutex_unlock(&mainobjstore_mutex);
996 pthread_mutex_unlock(&mainobjstore_mutex);
997 memcpy(ptrcreate, header, tmpsize);
998 mhashInsert(oidcreated[i], ptrcreate);
999 lhashInsert(oidcreated[i], myIpAddr);
1001 /* Unlock locked objects */
1002 for(i = 0; i < numlocked; i++) {
1003 if((header = (objheader_t *) mhashSearch(oidlocked[i])) == NULL) {
1004 printf("mhashsearch returns NULL at %s, %d\n", __FILE__, __LINE__);
1007 UnLock(STATUSPTR(header));
1013 prefetchpile_t *foundLocal(char *ptr) {
1014 int ntuples = *(GET_NTUPLES(ptr));
1015 unsigned int * oidarray = GET_PTR_OID(ptr);
1016 unsigned short * endoffsets = GET_PTR_EOFF(ptr, ntuples);
1017 short * arryfields = GET_PTR_ARRYFLD(ptr, ntuples);
1018 prefetchpile_t * head=NULL;
1021 for(i=0;i<ntuples; i++) {
1022 unsigned short baseindex=(i==0)?0:endoffsets[i-1];
1023 unsigned short endindex=endoffsets[i];
1024 unsigned int oid=oidarray[i];
1029 //Look up fields locally
1030 for(newbase=baseindex;newbase<endindex;newbase++) {
1031 if (!lookupObject(&oid, arryfields[newbase]))
1033 //Ended in a null pointer...
1037 //Entire prefetch is local
1038 if (newbase==endindex&&checkoid(oid))
1040 //Add to remote requests
1041 machinenum=lhashSearch(oid);
1042 insertPile(machinenum, oid, endindex-newbase, &arryfields[newbase], &head);
1049 int checkoid(unsigned int oid) {
1050 objheader_t *header;
1051 if ((header=mhashSearch(oid))!=NULL) {
1054 } else if ((header=prehashSearch(oid))!=NULL) {
1062 int lookupObject(unsigned int * oid, short offset) {
1063 objheader_t *header;
1064 if ((header=mhashSearch(*oid))!=NULL) {
1067 } else if ((header=prehashSearch(*oid))!=NULL) {
1074 if(TYPE(header) > NUMCLASSES) {
1075 int elementsize = classsize[TYPE(header)];
1076 struct ArrayObject *ao = (struct ArrayObject *) (((char *)header) + sizeof(objheader_t));
1077 int length = ao->___length___;
1078 /* Check if array out of bounds */
1079 if(offset < 0 || offset >= length) {
1080 //if yes treat the object as found
1084 (*oid) = *((unsigned int *)(((char *)ao) + sizeof(struct ArrayObject) + (elementsize*offset)));
1087 (*oid) = *((unsigned int *)(((char *)header) + sizeof(objheader_t) + offset));
1093 /* This function is called by the thread calling transPrefetch */
1094 void *transPrefetch(void *t) {
1096 /* lock mutex of primary prefetch queue */
1097 void *node=gettail();
1098 /* Check if the tuples are found locally, if yes then reduce them further*/
1099 /* and group requests by remote machine ids by calling the makePreGroups() */
1100 prefetchpile_t *pilehead = foundLocal(node);
1102 if (pilehead!=NULL) {
1103 // Get sock from shared pool
1104 int sd = getSock2(transPrefetchSockPool, pilehead->mid);
1106 /* Send Prefetch Request */
1107 prefetchpile_t *ptr = pilehead;
1108 while(ptr != NULL) {
1109 sendPrefetchReq(ptr, sd);
1113 /* Release socket */
1114 // freeSock(transPrefetchSockPool, pilehead->mid, sd);
1116 /* Deallocated pilehead */
1117 mcdealloc(pilehead);
1119 // Deallocate the prefetch queue pile node
1124 void sendPrefetchReqnew(prefetchpile_t *mcpilenode, int sd) {
1127 int size=sizeof(char)+sizeof(int);
1128 for(tmp=mcpilenode->objpiles;tmp!=NULL;tmp=tmp->next) {
1129 size += sizeof(int) + sizeof(unsigned int) + sizeof(unsigned int) + ((tmp->numoffset) * sizeof(short));
1134 *buf=TRANS_PREFETCH;
1137 for(tmp=mcpilenode->objpiles;tmp!=NULL;tmp=tmp->next) {
1138 int len = sizeof(int) + sizeof(unsigned int) + sizeof(unsigned int) + ((tmp->numoffset) * sizeof(short));
1141 *((unsigned int *)buf)=tmp->oid;
1142 buf+=sizeof(unsigned int);
1143 *((unsigned int *)(buf)) = myIpAddr;
1144 buf+=sizeof(unsigned int);
1145 memcpy(buf, tmp->offset, tmp->numoffset*sizeof(short));
1146 buf+=tmp->numoffset*sizeof(short);
1149 send_data(sd, buft, size);
1153 void sendPrefetchReq(prefetchpile_t *mcpilenode, int sd) {
1158 /* Send TRANS_PREFETCH control message */
1159 control = TRANS_PREFETCH;
1160 send_data(sd, &control, sizeof(char));
1162 /* Send Oids and offsets in pairs */
1163 tmp = mcpilenode->objpiles;
1164 while(tmp != NULL) {
1165 len = sizeof(int) + sizeof(unsigned int) + sizeof(unsigned int) + ((tmp->numoffset) * sizeof(short));
1166 char oidnoffset[len];
1167 char *buf=oidnoffset;
1168 *((int*)buf) = tmp->numoffset;
1170 *((unsigned int *)buf) = tmp->oid;
1171 buf+=sizeof(unsigned int);
1172 *((unsigned int *)buf) = myIpAddr;
1173 buf += sizeof(unsigned int);
1174 memcpy(buf, tmp->offset, tmp->numoffset*sizeof(short));
1175 send_data(sd, oidnoffset, len);
1179 /* Send a special char -1 to represent the end of sending oids + offset pair to remote machine */
1181 send_data(sd, &endpair, sizeof(int));
1186 int getPrefetchResponse(int sd) {
1187 int length = 0, size = 0;
1190 void *modptr, *oldptr;
1192 recv_data((int)sd, &length, sizeof(int));
1193 size = length - sizeof(int);
1194 char recvbuffer[size];
1196 recv_data((int)sd, recvbuffer, size);
1197 control = *((char *) recvbuffer);
1198 if(control == OBJECT_FOUND) {
1199 oid = *((unsigned int *)(recvbuffer + sizeof(char)));
1200 //printf("oid %d found\n",oid);
1201 size = size - (sizeof(char) + sizeof(unsigned int));
1202 pthread_mutex_lock(&prefetchcache_mutex);
1203 if ((modptr = objstrAlloc(prefetchcache, size)) == NULL) {
1204 printf("Error: objstrAlloc error for copying into prefetch cache %s, %d\n", __FILE__, __LINE__);
1205 pthread_mutex_unlock(&prefetchcache_mutex);
1208 pthread_mutex_unlock(&prefetchcache_mutex);
1209 memcpy(modptr, recvbuffer + sizeof(char) + sizeof(unsigned int), size);
1212 /* Insert the oid and its address into the prefetch hash lookup table */
1213 /* Do a version comparison if the oid exists */
1214 if((oldptr = prehashSearch(oid)) != NULL) {
1215 /* If older version then update with new object ptr */
1216 if(((objheader_t *)oldptr)->version <= ((objheader_t *)modptr)->version) {
1218 prehashInsert(oid, modptr);
1220 } else {/* Else add the object ptr to hash table*/
1221 prehashInsert(oid, modptr);
1223 /* Lock the Prefetch Cache look up table*/
1224 pthread_mutex_lock(&pflookup.lock);
1225 /* Broadcast signal on prefetch cache condition variable */
1226 pthread_cond_broadcast(&pflookup.cond);
1227 /* Unlock the Prefetch Cache look up table*/
1228 pthread_mutex_unlock(&pflookup.lock);
1229 } else if(control == OBJECT_NOT_FOUND) {
1230 oid = *((unsigned int *)(recvbuffer + sizeof(char)));
1231 /* TODO: For each object not found query DHT for new location and retrieve the object */
1232 /* Throw an error */
1233 printf("OBJECT %x NOT FOUND.... THIS SHOULD NOT HAPPEN...TERMINATE PROGRAM\n", oid);
1236 printf("Error: in decoding the control value %d, %s, %d\n",control, __FILE__, __LINE__);
1242 unsigned short getObjType(unsigned int oid) {
1243 objheader_t *objheader;
1244 unsigned short numoffset[] ={0};
1245 short fieldoffset[] ={};
1247 if ((objheader = (objheader_t *) mhashSearch(oid)) == NULL) {
1248 if ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) {
1249 prefetch(1, &oid, numoffset, fieldoffset);
1250 pthread_mutex_lock(&pflookup.lock);
1251 while ((objheader = (objheader_t *) prehashSearch(oid)) == NULL) {
1252 pthread_cond_wait(&pflookup.cond, &pflookup.lock);
1254 pthread_mutex_unlock(&pflookup.lock);
1258 return TYPE(objheader);
1261 int startRemoteThread(unsigned int oid, unsigned int mid)
1264 struct sockaddr_in remoteAddr;
1265 char msg[1 + sizeof(unsigned int)];
1269 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0)
1271 perror("startRemoteThread():socket()");
1275 bzero(&remoteAddr, sizeof(remoteAddr));
1276 remoteAddr.sin_family = AF_INET;
1277 remoteAddr.sin_port = htons(LISTEN_PORT);
1278 remoteAddr.sin_addr.s_addr = htonl(mid);
1280 if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0)
1282 printf("startRemoteThread():error %d connecting to %s:%d\n", errno,
1283 inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT);
1288 msg[0] = START_REMOTE_THREAD;
1289 *((unsigned int *) &msg[1]) = oid;
1290 send_data(sock, msg, 1 + sizeof(unsigned int));
1297 //TODO: when reusing oids, make sure they are not already in use!
1298 static unsigned int id = 0xFFFFFFFF;
1299 unsigned int getNewOID(void) {
1301 if (id > oidMax || id < oidMin)
1308 int processConfigFile()
1311 const int maxLineLength = 200;
1312 char lineBuffer[maxLineLength];
1314 const char *delimiters = " \t\n";
1318 configFile = fopen(CONFIG_FILENAME, "r");
1319 if (configFile == NULL)
1321 printf("error opening %s:\n", CONFIG_FILENAME);
1326 numHostsInSystem = 0;
1327 sizeOfHostArray = 8;
1328 hostIpAddrs = calloc(sizeOfHostArray, sizeof(unsigned int));
1330 while(fgets(lineBuffer, maxLineLength, configFile) != NULL)
1332 commentBegin = strchr(lineBuffer, '#');
1333 if (commentBegin != NULL)
1334 *commentBegin = '\0';
1335 token = strtok(lineBuffer, delimiters);
1336 while (token != NULL)
1338 tmpAddr = inet_addr(token);
1339 if ((int)tmpAddr == -1)
1341 printf("error in %s: bad token:%s\n", CONFIG_FILENAME, token);
1346 addHost(htonl(tmpAddr));
1347 token = strtok(NULL, delimiters);
1353 if (numHostsInSystem < 1)
1355 printf("error in %s: no IP Adresses found\n", CONFIG_FILENAME);
1359 myIpAddr = getMyIpAddr("en1");
1361 myIpAddr = getMyIpAddr("eth0");
1363 myIndexInHostArray = findHost(myIpAddr);
1364 if (myIndexInHostArray == -1)
1366 printf("error in %s: IP Address of eth0 not found\n", CONFIG_FILENAME);
1369 oidsPerBlock = (0xFFFFFFFF / numHostsInSystem) + 1;
1370 oidMin = oidsPerBlock * myIndexInHostArray;
1371 if (myIndexInHostArray == numHostsInSystem - 1)
1372 oidMax = 0xFFFFFFFF;
1374 oidMax = oidsPerBlock * (myIndexInHostArray + 1) - 1;
1379 void addHost(unsigned int hostIp)
1381 unsigned int *tmpArray;
1383 if (findHost(hostIp) != -1)
1386 if (numHostsInSystem == sizeOfHostArray)
1388 tmpArray = calloc(sizeOfHostArray * 2, sizeof(unsigned int));
1389 memcpy(tmpArray, hostIpAddrs, sizeof(unsigned int) * numHostsInSystem);
1391 hostIpAddrs = tmpArray;
1394 hostIpAddrs[numHostsInSystem++] = hostIp;
1399 int findHost(unsigned int hostIp)
1402 for (i = 0; i < numHostsInSystem; i++)
1403 if (hostIpAddrs[i] == hostIp)
1410 /* This function sends notification request per thread waiting on object(s) whose version
1412 int reqNotify(unsigned int *oidarry, unsigned short *versionarry, unsigned int numoid) {
1414 objheader_t *objheader;
1415 struct sockaddr_in remoteAddr;
1416 char msg[1 + numoid * (sizeof(unsigned short) + sizeof(unsigned int)) + 3 * sizeof(unsigned int)];
1420 unsigned short version;
1421 unsigned int oid,mid;
1422 static unsigned int threadid = 0;
1423 pthread_mutex_t threadnotify = PTHREAD_MUTEX_INITIALIZER; //Lock and condition var for threadjoin and notification
1424 pthread_cond_t threadcond = PTHREAD_COND_INITIALIZER;
1425 notifydata_t *ndata;
1428 if((mid = lhashSearch(oid)) == 0) {
1429 printf("Error: %s() No such machine found for oid =%x\n",__func__, oid);
1433 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){
1434 perror("reqNotify():socket()");
1438 bzero(&remoteAddr, sizeof(remoteAddr));
1439 remoteAddr.sin_family = AF_INET;
1440 remoteAddr.sin_port = htons(LISTEN_PORT);
1441 remoteAddr.sin_addr.s_addr = htonl(mid);
1443 /* Generate unique threadid */
1446 /* Save threadid, numoid, oidarray, versionarray, pthread_cond_variable for later processing */
1447 if((ndata = calloc(1, sizeof(notifydata_t))) == NULL) {
1448 printf("Calloc Error %s, %d\n", __FILE__, __LINE__);
1451 ndata->numoid = numoid;
1452 ndata->threadid = threadid;
1453 ndata->oidarry = oidarry;
1454 ndata->versionarry = versionarry;
1455 ndata->threadcond = threadcond;
1456 ndata->threadnotify = threadnotify;
1457 if((status = notifyhashInsert(threadid, ndata)) != 0) {
1458 printf("reqNotify(): Insert into notify hash table not successful %s, %d\n", __FILE__, __LINE__);
1463 /* Send number of oids, oidarry, version array, machine id and threadid */
1464 if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){
1465 printf("reqNotify():error %d connecting to %s:%d\n", errno,
1466 inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT);
1470 msg[0] = THREAD_NOTIFY_REQUEST;
1471 *((unsigned int *)(&msg[1])) = numoid;
1472 /* Send array of oids */
1473 size = sizeof(unsigned int);
1478 *((unsigned int *)(&msg[1] + size)) = oid;
1479 size += sizeof(unsigned int);
1484 /* Send array of version */
1488 version = versionarry[i];
1489 *((unsigned short *)(&msg[1] + size)) = version;
1490 size += sizeof(unsigned short);
1495 *((unsigned int *)(&msg[1] + size)) = myIpAddr;
1496 size += sizeof(unsigned int);
1497 *((unsigned int *)(&msg[1] + size)) = threadid;
1498 pthread_mutex_lock(&(ndata->threadnotify));
1499 size = 1 + numoid * (sizeof(unsigned int) + sizeof(unsigned short)) + 3 * sizeof(unsigned int);
1500 send_data(sock, msg, size);
1501 pthread_cond_wait(&(ndata->threadcond), &(ndata->threadnotify));
1502 pthread_mutex_unlock(&(ndata->threadnotify));
1505 pthread_cond_destroy(&threadcond);
1506 pthread_mutex_destroy(&threadnotify);
1512 void threadNotify(unsigned int oid, unsigned short version, unsigned int tid) {
1513 notifydata_t *ndata;
1514 int i, objIsFound = 0, index;
1517 //Look up the tid and call the corresponding pthread_cond_signal
1518 if((ndata = notifyhashSearch(tid)) == NULL) {
1519 printf("threadnotify(): No such threadid is present %s, %d\n", __FILE__, __LINE__);
1522 for(i = 0; i < ndata->numoid; i++) {
1523 if(ndata->oidarry[i] == oid){
1528 if(objIsFound == 0){
1529 printf("threadNotify(): Oid not found %s, %d\n", __FILE__, __LINE__);
1532 if(version <= ndata->versionarry[index]){
1533 printf("threadNotify(): New version %d has not changed since last version %s, %d\n", version, __FILE__, __LINE__);
1536 /* Clear from prefetch cache and free thread related data structure */
1537 if((ptr = prehashSearch(oid)) != NULL) {
1540 pthread_cond_signal(&(ndata->threadcond));
1547 int notifyAll(threadlist_t **head, unsigned int oid, unsigned int version) {
1550 struct sockaddr_in remoteAddr;
1551 char msg[1 + sizeof(unsigned short) + 2*sizeof(unsigned int)];
1552 int sock, status, size, bytesSent;
1554 while(*head != NULL) {
1557 //create a socket connection to that machine
1558 if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0){
1559 perror("notifyAll():socket()");
1563 bzero(&remoteAddr, sizeof(remoteAddr));
1564 remoteAddr.sin_family = AF_INET;
1565 remoteAddr.sin_port = htons(LISTEN_PORT);
1566 remoteAddr.sin_addr.s_addr = htonl(mid);
1567 //send Thread Notify response and threadid to that machine
1568 if (connect(sock, (struct sockaddr *)&remoteAddr, sizeof(remoteAddr)) < 0){
1569 printf("notifyAll():error %d connecting to %s:%d\n", errno,
1570 inet_ntoa(remoteAddr.sin_addr), LISTEN_PORT);
1574 bzero(msg, (1+sizeof(unsigned short) + 2*sizeof(unsigned int)));
1575 msg[0] = THREAD_NOTIFY_RESPONSE;
1576 *((unsigned int *)&msg[1]) = oid;
1577 size = sizeof(unsigned int);
1578 *((unsigned short *)(&msg[1]+ size)) = version;
1579 size+= sizeof(unsigned short);
1580 *((unsigned int *)(&msg[1]+ size)) = ptr->threadid;
1582 size = 1 + 2*sizeof(unsigned int) + sizeof(unsigned short);
1583 send_data(sock, msg, size);
1594 void transAbort(transrecord_t *trans) {
1595 objstrDelete(trans->cache);
1596 chashDelete(trans->lookupTable);